diff options
| author | Diego Nehab <diego@tecgraf.puc-rio.br> | 2005-03-11 02:21:27 +0000 |
|---|---|---|
| committer | Diego Nehab <diego@tecgraf.puc-rio.br> | 2005-03-11 02:21:27 +0000 |
| commit | 6dc9c1096a664fe3642e774aadcb5af9f511176e (patch) | |
| tree | 66a688e9854d801e594687fac6565da833952bbf /samples | |
| parent | e57f9e9964ac16b1fd09028ea533457f3029d296 (diff) | |
| download | luasocket-6dc9c1096a664fe3642e774aadcb5af9f511176e.tar.gz luasocket-6dc9c1096a664fe3642e774aadcb5af9f511176e.tar.bz2 luasocket-6dc9c1096a664fe3642e774aadcb5af9f511176e.zip | |
Seems to be working on windows.
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 |
