| 2 | #include "udp.h" |
| 3 | |
| 4 | static 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 | |
| 32 | static void mio(SOCK_UDP *sock, int inter, bool echo) |
| 33 | { |
no test coverage detected