代码拉取完成,页面将自动刷新
#include <iostream>
#include <sstream>
#include <sys/time.h>
#include <time.h>
#include <chrono>
#include <iomanip>
#include <string.h>
#include <erpc_server_setup.h>
#include "hello_server.h"
binary_t *sayHello(const binary_t *input)
{
struct timeval t_val;
struct tm* tm_l = NULL;
time_t tim_t;
size_t len = 0;
char *buf;
std::cout << "ServerHello called" << std::endl;
buf = (char *)malloc(input->dataLength + 21);
strncpy(buf, (const char *)input->data, input->dataLength);
gettimeofday(&t_val, NULL);
tim_t = t_val.tv_sec;
tm_l = localtime(&tim_t);
len = strftime(&buf[input->dataLength], 21, "@%Y-%m-%d %H:%M:%S", tm_l);
len = strlen(buf);
printf("data: %lu; %s\n", len, buf);
return new binary_t{(uint8_t*)buf, (uint32_t)len};
}
int main(int argc, char *argv[])
{
erpc_transport_t transport = erpc_transport_tcp_init("127.0.0.1", 5555, true);
erpc_mbf_t message_buffer_factory = erpc_mbf_dynamic_init();
erpc_server_init(transport, message_buffer_factory);
erpc_add_service_to_server(create_Hello_service());
while(1){
erpc_server_run();
}
erpc_transport_tcp_close();
return 0;
}
此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。