diff options
author | Diego Nehab <diego@tecgraf.puc-rio.br> | 2003-05-25 01:54:13 +0000 |
---|---|---|
committer | Diego Nehab <diego@tecgraf.puc-rio.br> | 2003-05-25 01:54:13 +0000 |
commit | 0f6c8d50a99997ac7829864b1c93362b50f1bbf3 (patch) | |
tree | d0cefe3a05484e65b7b7e79d8cae4a1d2e6d19fb /samples | |
parent | c1ef3e7103cc652d2004ef1ddc9409b946207f33 (diff) | |
download | luasocket-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.lua | 3 | ||||
-rw-r--r-- | samples/talker.lua | 12 |
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 | |||
7 | host = socket.toip(host) | 7 | host = socket.toip(host) |
8 | udp = socket.udp() | 8 | udp = socket.udp() |
9 | print("Using host '" ..host.. "' and port " ..port.. "...") | 9 | print("Using host '" ..host.. "' and port " ..port.. "...") |
10 | err = udp:sendto("anything", host, port) | 10 | udp:setpeername(host, port) |
11 | sent, err = udp:send("anything") | ||
11 | if err then print(err) exit() end | 12 | if err then print(err) exit() end |
12 | dgram, err = udp:receive() | 13 | dgram, err = udp:receive() |
13 | if not dgram then print(err) exit() end | 14 | if 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 |
6 | end | 6 | end |
7 | print("Attempting connection to host '" ..host.. "' and port " ..port.. "...") | 7 | print("Attempting connection to host '" ..host.. "' and port " ..port.. "...") |
8 | c, e = connect(host, port) | 8 | c, e = socket.connect(host, port) |
9 | if not c then | 9 | if not c then |
10 | print(e) | 10 | print(e) |
11 | exit() | 11 | os.exit() |
12 | end | 12 | end |
13 | print("Connected! Please type stuff (empty line to stop):") | 13 | print("Connected! Please type stuff (empty line to stop):") |
14 | l = read() | 14 | l = io.read() |
15 | while l and l ~= "" and not e do | 15 | while 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() |
22 | end | 22 | end |