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

Function run_client

lib_protocol/samples/httpd/main.c:195–237  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

193}
194
195static void run_client(const char *addr, const char *filename)
196{
197 char *request = acl_vstream_loadfile(filename);
198 ACL_VSTREAM *client;
199 int ret;
200 char buf[1024];
201
202 if (request == NULL) {
203 printf("load file(%s) error(%s)\n", filename, acl_last_serror());
204 return;
205 }
206
207 client = acl_vstream_connect(addr, ACL_BLOCKING,
208 0, 0, 4096);
209 if (client == NULL) {
210 printf("connect addr(%s) error(%s)\n", addr, acl_last_serror());
211 acl_myfree(request);
212 return;
213 }
214
215 acl_tcp_set_sndbuf(ACL_VSTREAM_SOCK(client), 10);
216 if (acl_vstream_writen(client, request, strlen(request)) == ACL_VSTREAM_EOF) {
217 printf("write to addr(%s) error(%s)\n", addr, acl_last_serror());
218 acl_vstream_close(client);
219 acl_myfree(request);
220 return;
221 }
222
223 memset(buf, 0, sizeof(buf));
224
225 while (1) {
226 ret = acl_vstream_read(client, buf, sizeof(buf) - 1);
227 if (ret == ACL_VSTREAM_EOF)
228 break;
229 buf[ret] = 0;
230 usleep(100000);
231 printf(">>>%s\n", buf);
232 }
233
234 printf(">>>last data(%s)\n", buf);
235 acl_vstream_close(client);
236 acl_myfree(request);
237}
238
239static void usage(const char *procname)
240{

Callers 1

mainFunction · 0.70

Calls 7

acl_vstream_loadfileFunction · 0.85
acl_last_serrorFunction · 0.85
acl_vstream_connectFunction · 0.85
acl_tcp_set_sndbufFunction · 0.85
acl_vstream_writenFunction · 0.85
acl_vstream_closeFunction · 0.85
acl_vstream_readFunction · 0.85

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…