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

Function sio

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

Source from the content-addressed store, hash-verified

2#include "udp.h"
3
4static void sio(SOCK_UDP *sock, int inter, bool echo)
5{
6 int i = 0, ret;
7 char buf[4096];
8
9 while (true) {
10 ret = udp_read(sock, buf, sizeof(buf) - 1);
11 if (ret == -1) {
12 printf("sock_read error %s\r\n", acl_last_serror());
13 break;
14 } else
15 buf[ret] = 0;
16
17// if (++i % inter == 0)
18 printf("result: %s\r\n", buf);
19
20 if (echo && (ret = udp_send(sock, buf, ret)) == -1) {
21 printf("sock_write error %s\r\n", acl_last_serror());
22 break;
23 }
24
25 if (i % inter == 0) {
26 snprintf(buf, sizeof(buf), "curr: %d, dlen=%d", i, ret);
27 ACL_METER_TIME(buf);
28 }
29 }
30}
31
32static void mio(SOCK_UDP *sock, int inter, bool echo)
33{

Callers 1

runFunction · 0.70

Calls 3

acl_last_serrorFunction · 0.85
udp_sendFunction · 0.85
udp_readFunction · 0.50

Tested by

no test coverage detected