diff options
| author | Diego Nehab <diego@tecgraf.puc-rio.br> | 2005-11-22 08:33:29 +0000 |
|---|---|---|
| committer | Diego Nehab <diego@tecgraf.puc-rio.br> | 2005-11-22 08:33:29 +0000 |
| commit | d55a5826e81136a9ecf65c4cd407152a56684dc2 (patch) | |
| tree | 109ad44c75cee890ad5e98583e12b15b5e65a18e /samples/tinyirc.lua | |
| parent | a2b780bf7a78c66d54a248fa99b5fc862c12a127 (diff) | |
| download | luasocket-d55a5826e81136a9ecf65c4cd407152a56684dc2.tar.gz luasocket-d55a5826e81136a9ecf65c4cd407152a56684dc2.tar.bz2 luasocket-d55a5826e81136a9ecf65c4cd407152a56684dc2.zip | |
Few tweaks in installation, some missing files, etc.
Diffstat (limited to 'samples/tinyirc.lua')
| -rw-r--r-- | samples/tinyirc.lua | 10 |
1 files changed, 5 insertions, 5 deletions
diff --git a/samples/tinyirc.lua b/samples/tinyirc.lua index e3dd517..dd2c6f8 100644 --- a/samples/tinyirc.lua +++ b/samples/tinyirc.lua | |||
| @@ -62,24 +62,24 @@ while 1 do | |||
| 62 | if input == server1 or input == server2 then | 62 | if input == server1 or input == server2 then |
| 63 | io.write("Waiting for clients\n") | 63 | io.write("Waiting for clients\n") |
| 64 | local new = input:accept() | 64 | local new = input:accept() |
| 65 | if new then | 65 | if new then |
| 66 | new:settimeout(1) | 66 | new:settimeout(1) |
| 67 | io.write("Inserting client in set\n") | 67 | io.write("Inserting client in set\n") |
| 68 | set:insert(new) | 68 | set:insert(new) |
| 69 | end | 69 | end |
| 70 | -- it is a client socket | 70 | -- it is a client socket |
| 71 | else | 71 | else |
| 72 | local line, error = input:receive() | 72 | local line, error = input:receive() |
| 73 | if error then | 73 | if error then |
| 74 | input:close() | 74 | input:close() |
| 75 | io.write("Removing client from set\n") | 75 | io.write("Removing client from set\n") |
| 76 | set:remove(input) | 76 | set:remove(input) |
| 77 | else | 77 | else |
| 78 | io.write("Broadcasting line '", line, "'\n") | 78 | io.write("Broadcasting line '", line, "'\n") |
| 79 | writable, error = socket.skip(1, socket.select(nil, set, 1)) | 79 | writable, error = socket.skip(1, socket.select(nil, set, 1)) |
| 80 | if not error then | 80 | if not error then |
| 81 | for __, output in ipairs(writable) do | 81 | for __, output in ipairs(writable) do |
| 82 | if output ~= input then | 82 | if output ~= input then |
| 83 | output:send(line .. "\n") | 83 | output:send(line .. "\n") |
| 84 | end | 84 | end |
| 85 | end | 85 | end |
