-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathserver.c
More file actions
77 lines (60 loc) · 1.26 KB
/
Copy pathserver.c
File metadata and controls
77 lines (60 loc) · 1.26 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <unistd.h>
#include <sys/types.h>
#include <sys/socket.h>
#include <netinet/in.h>
#include <arpa/inet.h>
#include <sys/time.h>
#include <errno.h>
#include "config.h"
#include "net_service.h"
#include "net_server.h"
#include "net_comm.h"
#include "cJSON.h"
cJSON *service_test1(cJSON *data)
{
printf("service_test1\n");
return NULL;
}
cJSON *service_test2(cJSON *data)
{
printf("service_test2\n");
return NULL;
}
int test_function2(void *param)
{
int ret = -1;
ServerT *server;
service_init();
service_register("test1", &service_test1, NULL);
service_register("test2", &service_test2, NULL);
ret = server_init();
if (ret < 0)
{
printf("server err...\n");
return ret;
}
ret = server_open(&server, 0);
if (ret < 0)
{
printf("server err...\n");
return ret;
}
printf("server start...\n");
server_start(server);
server_close(&server);
return ret;
}
int main(void)
{
//char *buf = "{ \"abc\":2, { ";
//const char *end;
//const char *cur;
//cJSON *root;
//root = cJSON_ParseWithOpts(buf, &end, 0);
//cur = cJSON_GetErrorPtr();
test_function2(NULL);
return 0;
}