diff options
| author | Diego Nehab <diego@tecgraf.puc-rio.br> | 2003-08-16 00:06:04 +0000 |
|---|---|---|
| committer | Diego Nehab <diego@tecgraf.puc-rio.br> | 2003-08-16 00:06:04 +0000 |
| commit | c51d4acf1c2a8675a3bb043e799ff4390cef47d6 (patch) | |
| tree | 345b71aa70b50c964a58980461e147a260fa6e0b /samples | |
| parent | 3099704affa1fda195eb8f3934f6c1f18bf1f706 (diff) | |
| download | luasocket-c51d4acf1c2a8675a3bb043e799ff4390cef47d6.tar.gz luasocket-c51d4acf1c2a8675a3bb043e799ff4390cef47d6.tar.bz2 luasocket-c51d4acf1c2a8675a3bb043e799ff4390cef47d6.zip | |
Adjusted a few inconsistencies with the manual.
Diffstat (limited to 'samples')
| -rw-r--r-- | samples/daytimeclnt.lua | 2 | ||||
| -rw-r--r-- | samples/echoclnt.lua | 12 | ||||
| -rw-r--r-- | samples/echosrvr.lua | 9 | ||||
| -rw-r--r-- | samples/tinyirc.lua | 6 |
4 files changed, 15 insertions, 14 deletions
diff --git a/samples/daytimeclnt.lua b/samples/daytimeclnt.lua index 5064fff..29abe17 100644 --- a/samples/daytimeclnt.lua +++ b/samples/daytimeclnt.lua | |||
| @@ -10,7 +10,7 @@ if arg then | |||
| 10 | host = arg[1] or host | 10 | host = arg[1] or host |
| 11 | port = arg[2] or port | 11 | port = arg[2] or port |
| 12 | end | 12 | end |
| 13 | host = socket.toip(host) | 13 | host = socket.dns.toip(host) |
| 14 | udp = socket.udp() | 14 | udp = socket.udp() |
| 15 | print("Using host '" ..host.. "' and port " ..port.. "...") | 15 | print("Using host '" ..host.. "' and port " ..port.. "...") |
| 16 | udp:setpeername(host, port) | 16 | udp:setpeername(host, port) |
diff --git a/samples/echoclnt.lua b/samples/echoclnt.lua index e028b86..56bd123 100644 --- a/samples/echoclnt.lua +++ b/samples/echoclnt.lua | |||
| @@ -10,17 +10,17 @@ if arg then | |||
| 10 | host = arg[1] or host | 10 | host = arg[1] or host |
| 11 | port = arg[2] or port | 11 | port = arg[2] or port |
| 12 | end | 12 | end |
| 13 | host = socket.toip(host) | 13 | host = socket.dns.toip(host) |
| 14 | udp, err = socket.udp() | 14 | udp, err = socket.udp() |
| 15 | if not udp then print(err) exit() end | 15 | assert(udp, err) |
| 16 | err = udp:setpeername(host, port) | 16 | ret, err = udp:setpeername(host, port) |
| 17 | if err then print(err) exit() end | 17 | assert(ret, err) |
| 18 | print("Using host '" ..host.. "' and port " .. port .. "...") | 18 | print("Using host '" ..host.. "' and port " .. port .. "...") |
| 19 | while 1 do | 19 | while 1 do |
| 20 | line = io.read() | 20 | line = io.read() |
| 21 | if not line then os.exit() end | 21 | if not line then os.exit() end |
| 22 | err = udp:send(line) | 22 | ret, err = udp:send(line) |
| 23 | if err then print(err) os.exit() end | 23 | if not ret then print(err) os.exit() end |
| 24 | dgram, err = udp:receive() | 24 | dgram, err = udp:receive() |
| 25 | if not dgram then print(err) os.exit() end | 25 | if not dgram then print(err) os.exit() end |
| 26 | print(dgram) | 26 | print(dgram) |
diff --git a/samples/echosrvr.lua b/samples/echosrvr.lua index 127ccb8..a7ed03c 100644 --- a/samples/echosrvr.lua +++ b/samples/echosrvr.lua | |||
| @@ -12,11 +12,12 @@ if arg then | |||
| 12 | end | 12 | end |
| 13 | print("Binding to host '" ..host.. "' and port " ..port.. "...") | 13 | print("Binding to host '" ..host.. "' and port " ..port.. "...") |
| 14 | udp, err = socket.udp() | 14 | udp, err = socket.udp() |
| 15 | if not udp then print(err) os.exit() end | 15 | assert(udp, err) |
| 16 | err = udp:setsockname(host, port) | 16 | ret, err = udp:setsockname(host, port) |
| 17 | if err then print(err) os.exit() end | 17 | assert(ret, err) |
| 18 | udp:timeout(5) | 18 | udp:settimeout(5) |
| 19 | ip, port = udp:getsockname() | 19 | ip, port = udp:getsockname() |
| 20 | assert(ip, port) | ||
| 20 | print("Waiting packets on " .. ip .. ":" .. port .. "...") | 21 | print("Waiting packets on " .. ip .. ":" .. port .. "...") |
| 21 | while 1 do | 22 | while 1 do |
| 22 | dgram, ip, port = udp:receivefrom() | 23 | dgram, ip, port = udp:receivefrom() |
diff --git a/samples/tinyirc.lua b/samples/tinyirc.lua index d9cb896..b48b90a 100644 --- a/samples/tinyirc.lua +++ b/samples/tinyirc.lua | |||
| @@ -15,10 +15,10 @@ end | |||
| 15 | 15 | ||
| 16 | server1, error = socket.bind(host, port1) | 16 | server1, error = socket.bind(host, port1) |
| 17 | assert(server1, error) | 17 | assert(server1, error) |
| 18 | server1:timeout(1) -- make sure we don't block in accept | 18 | server1:settimeout(1) -- make sure we don't block in accept |
| 19 | server2, error = socket.bind(host, port2) | 19 | server2, error = socket.bind(host, port2) |
| 20 | assert(server2, error) | 20 | assert(server2, error) |
| 21 | server2:timeout(1) -- make sure we don't block in accept | 21 | server2:settimeout(1) -- make sure we don't block in accept |
| 22 | 22 | ||
| 23 | io.write("Servers bound\n") | 23 | io.write("Servers bound\n") |
| 24 | 24 | ||
| @@ -55,7 +55,7 @@ while 1 do | |||
| 55 | io.write("Waiting for clients\n") | 55 | io.write("Waiting for clients\n") |
| 56 | local new = input:accept() | 56 | local new = input:accept() |
| 57 | if new then | 57 | if new then |
| 58 | new:timeout(1) | 58 | new:settimeout(1) |
| 59 | io.write("Inserting client in set\n") | 59 | io.write("Inserting client in set\n") |
| 60 | set:insert(new) | 60 | set:insert(new) |
| 61 | end | 61 | end |
