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

Function main

lib_acl_cpp/samples/benchmark/server/main.cpp:106–173  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

104}
105
106int main(int argc, char* argv[])
107{
108 acl::acl_cpp_init();
109
110 acl::string addr("127.0.0.1:8888");
111 int ch;
112 bool separate = false;
113
114 while ((ch = getopt(argc, argv, "hs:p")) > 0 )
115 {
116 switch (ch)
117 {
118 case 'h':
119 usage(argv[0]);
120 return 0;
121 case 's':
122 addr = optarg;
123 break;
124 case 'p':
125 separate = true;
126 break;
127 default:
128 usage(argv[0]);
129 return 0;
130 }
131 }
132
133 acl::server_socket server;
134 if (server.open(addr) == false)
135 {
136 printf("listen %s error\r\n", addr.c_str());
137 return -1;
138 }
139 else
140 printf("listen %s ok\r\n", addr.c_str());
141
142 // 接收一个客户端连接
143 acl::socket_stream* conn = server.accept();
144 if (conn == NULL)
145 {
146 printf("accept error %s\r\n", acl::last_serror());
147 return -1;
148 }
149 else
150 printf("accept on client: %s\r\n", conn->get_peer());
151
152 if (!separate)
153 {
154 handle_connection(conn);
155 delete conn;
156 return 0;
157 }
158
159 acl_pthread_attr_t attr;
160 acl_pthread_attr_init(&attr);
161 acl_pthread_attr_setdetachstate(&attr, 0);
162
163 acl_pthread_t tid_read, tid_write;

Callers

nothing calls this directly

Calls 13

acl_cpp_initFunction · 0.85
acl_pthread_attr_initFunction · 0.85
acl_pthread_createFunction · 0.85
acl_pthread_joinFunction · 0.85
usageFunction · 0.70
handle_connectionFunction · 0.70
getoptFunction · 0.50
last_serrorFunction · 0.50
openMethod · 0.45
c_strMethod · 0.45
acceptMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…