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

Function main

lib_acl/samples/udp/server/main.cpp:141–203  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

139}
140
141int main(int argc, char *argv[])
142{
143 char local[64];
144 int ch, inter = 1000, nthreads = 1;
145 int need_echo = 0, mio_on = 0;
146
147 acl_lib_init();
148 acl_msg_stdout_enable(1);
149
150 snprintf(local, sizeof(local), "127.0.0.1:8888");
151
152 while ((ch = getopt(argc, argv, "hs:i:t:em")) > 0) {
153 switch (ch) {
154 case 'h':
155 usage(argv[0]);
156 return 0;
157 case 's':
158 snprintf(local, sizeof(local), "%s", optarg);
159 break;
160 case 'i':
161 inter = atoi(optarg);
162 break;
163 case 't':
164 nthreads = atoi(optarg);
165 break;
166 case 'e':
167 need_echo = 1;
168 break;
169 case 'm':
170 mio_on = 1;
171 break;
172 default:
173 break;
174 }
175 }
176
177 if (local[0] == 0) {
178 usage(argv[0]);
179 return 1;
180 }
181
182 if (nthreads > 1) {
183 int i;
184 acl_pthread_pool_t *threads =
185 acl_thread_pool_create(nthreads, 120);
186 for (i = 0; i < nthreads; i++) {
187 THREAD_CTX *ctx = (THREAD_CTX*)
188 acl_mymalloc(sizeof(THREAD_CTX));
189 snprintf(ctx->local, sizeof(ctx->local), "%s", local);
190 ctx->inter = inter;
191 ctx->need_echo = need_echo;
192 ctx->mio_on = mio_on;
193 acl_pthread_pool_add(threads, thread_run, ctx);
194 }
195
196 acl_pthread_pool_destroy(threads);
197 } else
198 run(local, inter, mio_on, need_echo);

Callers

nothing calls this directly

Calls 8

acl_lib_initFunction · 0.85
acl_msg_stdout_enableFunction · 0.85
acl_thread_pool_createFunction · 0.85
acl_pthread_pool_destroyFunction · 0.85
acl_lib_endFunction · 0.85
usageFunction · 0.70
runFunction · 0.70
getoptFunction · 0.50

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…