aboutsummaryrefslogtreecommitdiff
path: root/samples
diff options
context:
space:
mode:
authorDiego Nehab <diego@tecgraf.puc-rio.br>2003-05-25 01:54:13 +0000
committerDiego Nehab <diego@tecgraf.puc-rio.br>2003-05-25 01:54:13 +0000
commit0f6c8d50a99997ac7829864b1c93362b50f1bbf3 (patch)
treed0cefe3a05484e65b7b7e79d8cae4a1d2e6d19fb /samples
parentc1ef3e7103cc652d2004ef1ddc9409b946207f33 (diff)
downloadluasocket-0f6c8d50a99997ac7829864b1c93362b50f1bbf3.tar.gz
luasocket-0f6c8d50a99997ac7829864b1c93362b50f1bbf3.tar.bz2
luasocket-0f6c8d50a99997ac7829864b1c93362b50f1bbf3.zip
Porting to LUA 5.0 final
Diffstat (limited to 'samples')
-rw-r--r--samples/daytimeclnt.lua3
-rw-r--r--samples/talker.lua12
2 files changed, 8 insertions, 7 deletions
diff --git a/samples/daytimeclnt.lua b/samples/daytimeclnt.lua
index 000dfd5..4debc81 100644
--- a/samples/daytimeclnt.lua
+++ b/samples/daytimeclnt.lua
@@ -7,7 +7,8 @@ end
7host = socket.toip(host) 7host = socket.toip(host)
8udp = socket.udp() 8udp = socket.udp()
9print("Using host '" ..host.. "' and port " ..port.. "...") 9print("Using host '" ..host.. "' and port " ..port.. "...")
10err = udp:sendto("anything", host, port) 10udp:setpeername(host, port)
11sent, err = udp:send("anything")
11if err then print(err) exit() end 12if err then print(err) exit() end
12dgram, err = udp:receive() 13dgram, err = udp:receive()
13if not dgram then print(err) exit() end 14if not dgram then print(err) exit() end
diff --git a/samples/talker.lua b/samples/talker.lua
index d66cf66..688824f 100644
--- a/samples/talker.lua
+++ b/samples/talker.lua
@@ -5,18 +5,18 @@ if arg then
5 port = arg[2] or port 5 port = arg[2] or port
6end 6end
7print("Attempting connection to host '" ..host.. "' and port " ..port.. "...") 7print("Attempting connection to host '" ..host.. "' and port " ..port.. "...")
8c, e = connect(host, port) 8c, e = socket.connect(host, port)
9if not c then 9if not c then
10 print(e) 10 print(e)
11 exit() 11 os.exit()
12end 12end
13print("Connected! Please type stuff (empty line to stop):") 13print("Connected! Please type stuff (empty line to stop):")
14l = read() 14l = io.read()
15while l and l ~= "" and not e do 15while l and l ~= "" and not e do
16 e = c:send(l, "\n") 16 t, e = c:send(l, "\n")
17 if e then 17 if e then
18 print(e) 18 print(e)
19 exit() 19 os.exit()
20 end 20 end
21 l = read() 21 l = io.read()
22end 22end