diff options
| author | ruki <[email protected]> | 2019-10-15 22:33:24 +0800 |
|---|---|---|
| committer | ruki <[email protected]> | 2019-10-15 09:20:28 +0800 |
| commit | e915ad63a7f1a9fa4736472c60b0550cbd174361 (patch) | |
| tree | fdaaab30b6d174e4932cc59766dc350dcdff7726 /tests/modules/socket/tcp/echo_server.lua | |
| parent | 194434ebd67911dfd8352bc8c50b463b191e85c1 (diff) | |
move socket test files
Diffstat (limited to 'tests/modules/socket/tcp/echo_server.lua')
| -rw-r--r-- | tests/modules/socket/tcp/echo_server.lua | 18 |
1 files changed, 18 insertions, 0 deletions
diff --git a/tests/modules/socket/tcp/echo_server.lua b/tests/modules/socket/tcp/echo_server.lua new file mode 100644 index 000000000..76aa9dfb6 --- /dev/null +++ b/tests/modules/socket/tcp/echo_server.lua @@ -0,0 +1,18 @@ +import("core.base.socket") + +function main() + local sock = socket.bind("127.0.0.1", 9001) + sock:listen(20) + local sock_client = nil + while true do + 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) + sock_client:close() + end + end + end + sock:close() +end |
