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

Function sio

lib_acl/samples/udp/client/main.cpp:20–54  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

18}
19
20static int sio(SOCK_UDP *sock, const char *data, int dlen, int count,
21 int inter, bool need_read)
22{
23 int i, ret;
24 char buf[4096];
25
26 for (i = 0; i < count; i++) {
27 ret = udp_send(sock, data, dlen);
28 if (ret == -1) {
29 printf("sock_write error %s\r\n", acl_last_serror());
30 break;
31 }
32
33 if (need_read) {
34 ret = udp_read(sock, buf, sizeof(buf) - 1);
35 if (ret == -1) {
36 printf("sock_read error %s\r\n",
37 acl_last_serror());
38 break;
39 } else
40 buf[ret] = 0;
41 if (i % inter == 0)
42 printf("result: %s\r\n", buf);
43 }
44
45 if (i % inter == 0) {
46 snprintf(buf, sizeof(buf),
47 "total: %d, curr: %d, dlen=%d",
48 count, i, dlen);
49 ACL_METER_TIME(buf);
50 }
51 }
52
53 return i;
54}
55
56static int mio(SOCK_UDP *sock, const char *peer_addr, int dlen,
57 int count, int inter, bool echo)

Callers 1

runFunction · 0.70

Calls 3

udp_sendFunction · 0.85
acl_last_serrorFunction · 0.85
udp_readFunction · 0.50

Tested by

no test coverage detected