summaryrefslogtreecommitdiff
path: root/tests/modules/socket/echo_server.lua
blob: 76aa9dfb651113e7d53f3b3ca0ab26666a735205 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
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