diff options
Diffstat (limited to 'samples')
-rw-r--r-- | samples/forward.lua | 7 |
1 files changed, 3 insertions, 4 deletions
diff --git a/samples/forward.lua b/samples/forward.lua index 46f51c8..fe0d20a 100644 --- a/samples/forward.lua +++ b/samples/forward.lua | |||
@@ -57,7 +57,7 @@ function init() | |||
57 | assert(iport, "invalid arguments") | 57 | assert(iport, "invalid arguments") |
58 | -- create our server socket | 58 | -- create our server socket |
59 | local server = assert(socket.bind("*", iport)) | 59 | local server = assert(socket.bind("*", iport)) |
60 | server:settimeout(0.1) -- we don't want to be killed by bad luck | 60 | server:settimeout(0) -- we don't want to be killed by bad luck |
61 | -- make sure server is tested for readability | 61 | -- make sure server is tested for readability |
62 | receiving:insert(server) | 62 | receiving:insert(server) |
63 | -- add server context | 63 | -- add server context |
@@ -71,7 +71,7 @@ end | |||
71 | 71 | ||
72 | -- starts a connection in a non-blocking way | 72 | -- starts a connection in a non-blocking way |
73 | function connect(who, host, port) | 73 | function connect(who, host, port) |
74 | who:settimeout(0.1) | 74 | who:settimeout(0) |
75 | print("trying to connect peer", who, host, port) | 75 | print("trying to connect peer", who, host, port) |
76 | local ret, err = who:connect(host, port) | 76 | local ret, err = who:connect(host, port) |
77 | if not ret and err == "timeout" then | 77 | if not ret and err == "timeout" then |
@@ -89,12 +89,11 @@ print("connection failed", who) | |||
89 | end | 89 | end |
90 | end | 90 | end |
91 | 91 | ||
92 | -- gets rid of a client and its peer | 92 | -- gets rid of a client |
93 | function kick(who) | 93 | function kick(who) |
94 | if who and context[who] then | 94 | if who and context[who] then |
95 | sending:remove(who) | 95 | sending:remove(who) |
96 | receiving:remove(who) | 96 | receiving:remove(who) |
97 | local peer = context[who].peer | ||
98 | context[who] = nil | 97 | context[who] = nil |
99 | who:close() | 98 | who:close() |
100 | end | 99 | end |