diff options
| author | ruki <[email protected]> | 2019-10-16 00:48:50 +0800 |
|---|---|---|
| committer | ruki <[email protected]> | 2019-10-15 22:53:03 +0800 |
| commit | 690dc274a4d5f9f443e6c2004b985b03345874d6 (patch) | |
| tree | 43b6ba534d331325ca8d4022994bda75e496e5eb /tests/modules/socket/tcp/echo_server.lua | |
| parent | e915ad63a7f1a9fa4736472c60b0550cbd174361 (diff) | |
add socket.send
Diffstat (limited to 'tests/modules/socket/tcp/echo_server.lua')
| -rw-r--r-- | tests/modules/socket/tcp/echo_server.lua | 7 |
1 files changed, 5 insertions, 2 deletions
diff --git a/tests/modules/socket/tcp/echo_server.lua b/tests/modules/socket/tcp/echo_server.lua index 76aa9dfb6..a047aa15f 100644 --- a/tests/modules/socket/tcp/echo_server.lua +++ b/tests/modules/socket/tcp/echo_server.lua @@ -1,15 +1,18 @@ import("core.base.socket") function main() - local sock = socket.bind("127.0.0.1", 9001) + local addr = "127.0.0.1" + local port = 9001 + local sock = socket.bind(addr, port) sock:listen(20) local sock_client = nil while true do + print("%s: listening %s:%d ..", sock, addr, port) local ok = sock:wait(socket.EV_ACPT, -1) if ok == socket.EV_ACPT then sock_client = sock:accept() if sock_client then - print(sock_client) + print("%s: accepted", sock_client) sock_client:close() end end |
