From c51d4acf1c2a8675a3bb043e799ff4390cef47d6 Mon Sep 17 00:00:00 2001 From: Diego Nehab Date: Sat, 16 Aug 2003 00:06:04 +0000 Subject: Adjusted a few inconsistencies with the manual. --- samples/daytimeclnt.lua | 2 +- samples/echoclnt.lua | 12 ++++++------ samples/echosrvr.lua | 9 +++++---- samples/tinyirc.lua | 6 +++--- 4 files changed, 15 insertions(+), 14 deletions(-) (limited to 'samples') 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 host = arg[1] or host port = arg[2] or port end -host = socket.toip(host) +host = socket.dns.toip(host) udp = socket.udp() print("Using host '" ..host.. "' and port " ..port.. "...") 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 host = arg[1] or host port = arg[2] or port end -host = socket.toip(host) +host = socket.dns.toip(host) udp, err = socket.udp() -if not udp then print(err) exit() end -err = udp:setpeername(host, port) -if err then print(err) exit() end +assert(udp, err) +ret, err = udp:setpeername(host, port) +assert(ret, err) print("Using host '" ..host.. "' and port " .. port .. "...") while 1 do line = io.read() if not line then os.exit() end - err = udp:send(line) - if err then print(err) os.exit() end + ret, err = udp:send(line) + if not ret then print(err) os.exit() end dgram, err = udp:receive() if not dgram then print(err) os.exit() end 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 end print("Binding to host '" ..host.. "' and port " ..port.. "...") udp, err = socket.udp() -if not udp then print(err) os.exit() end -err = udp:setsockname(host, port) -if err then print(err) os.exit() end -udp:timeout(5) +assert(udp, err) +ret, err = udp:setsockname(host, port) +assert(ret, err) +udp:settimeout(5) ip, port = udp:getsockname() +assert(ip, port) print("Waiting packets on " .. ip .. ":" .. port .. "...") while 1 do 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 server1, error = socket.bind(host, port1) assert(server1, error) -server1:timeout(1) -- make sure we don't block in accept +server1:settimeout(1) -- make sure we don't block in accept server2, error = socket.bind(host, port2) assert(server2, error) -server2:timeout(1) -- make sure we don't block in accept +server2:settimeout(1) -- make sure we don't block in accept io.write("Servers bound\n") @@ -55,7 +55,7 @@ while 1 do io.write("Waiting for clients\n") local new = input:accept() if new then - new:timeout(1) + new:settimeout(1) io.write("Inserting client in set\n") set:insert(new) end -- cgit v1.2.3-55-g6feb