diff options
| author | ruki <[email protected]> | 2019-11-03 22:19:55 +0800 |
|---|---|---|
| committer | ruki <[email protected]> | 2019-11-03 22:19:55 +0800 |
| commit | 8eddfb0d678d6ea5427ae55e9dff108fde5add42 (patch) | |
| tree | cac98a7120db66447cf48b6b6c1bdf2d05be04a4 /tests/modules/socket/udp/echo_server.lua | |
| parent | b0a7b7a70cafc7988a33e1856147622b0ea92559 (diff) | |
add socket.sendto and socket.recvfrom
Diffstat (limited to 'tests/modules/socket/udp/echo_server.lua')
| -rw-r--r-- | tests/modules/socket/udp/echo_server.lua | 14 |
1 files changed, 14 insertions, 0 deletions
diff --git a/tests/modules/socket/udp/echo_server.lua b/tests/modules/socket/udp/echo_server.lua new file mode 100644 index 000000000..98cf72f7c --- /dev/null +++ b/tests/modules/socket/udp/echo_server.lua @@ -0,0 +1,14 @@ +import("core.base.socket") + +function main() + local sock = socket.udp() + while true do + print("%s: recv ..", sock) + local recv, data, addr, port = sock:recv(8192, {block = true}) + print("%s: recv: %d bytes from: %s:%d", sock, recv, addr, port) + if data then + data:dump() + end + end + sock:close() +end |
