MCPcopy Create free account
hub / github.com/acl-dev/acl / main

Function main

lib_acl_cpp/samples/socket/server/main.cpp:5–53  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

3#include <stdio.h>
4
5int main(int argc, char* argv[])
6{
7 acl::server_socket server;
8 acl::string addr = "127.0.0.1:9001";
9
10 if (argc >= 2)
11 addr = argv[1];
12
13 acl::acl_cpp_init();
14
15 if (server.open(addr) == false)
16 {
17 printf("open %s error %s\r\n", addr.c_str(), acl::last_serror());
18 return 1;
19 }
20 else
21 printf("open %s ok\r\n", addr.c_str());
22
23 while (true)
24 {
25 acl::socket_stream* client = server.accept();
26 if (client == NULL)
27 {
28 printf("accept failed: %s\r\n", acl::last_serror());
29 break;
30 }
31
32 printf("before set sendbuf's size: %d, readbuf's size: %d\r\n",
33 client->get_tcp_sendbuf(), client->get_tcp_recvbuf());
34
35 client->set_tcp_sendbuf(1024000);
36 client->set_tcp_recvbuf(2048000);
37
38 printf("after set sendbuf's size: %d, readbuf's size: %d\r\n",
39 client->get_tcp_sendbuf(), client->get_tcp_recvbuf());
40
41 if (client->write("hello world\r\n") == -1)
42 {
43 printf("write error\r\n");
44 delete client;
45 continue;
46 }
47
48 delete client;
49 printf("close client ok\r\n");
50 }
51
52 return (0);
53}

Callers

nothing calls this directly

Calls 8

acl_cpp_initFunction · 0.85
get_tcp_sendbufMethod · 0.80
get_tcp_recvbufMethod · 0.80
last_serrorFunction · 0.50
openMethod · 0.45
c_strMethod · 0.45
acceptMethod · 0.45
writeMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…