diff options
author | Diego Nehab <diego@tecgraf.puc-rio.br> | 2001-03-06 19:46:42 +0000 |
---|---|---|
committer | Diego Nehab <diego@tecgraf.puc-rio.br> | 2001-03-06 19:46:42 +0000 |
commit | 2c9008772ef9c015569204bede90152ed975d0cc (patch) | |
tree | ceba0f04392962929d63eaafeb3c51fadb60a67e | |
parent | 29226588da627587cacc40605b24c3eea01c2a8e (diff) | |
download | luasocket-2c9008772ef9c015569204bede90152ed975d0cc.tar.gz luasocket-2c9008772ef9c015569204bede90152ed975d0cc.tar.bz2 luasocket-2c9008772ef9c015569204bede90152ed975d0cc.zip |
Updated to remove use of global methods. Conforming to
LuaSocket release 1.2.1
-rw-r--r-- | etc/dict.lua | 12 | ||||
-rw-r--r-- | samples/echoclnt.lua | 8 | ||||
-rw-r--r-- | samples/echosrvr.lua | 10 |
3 files changed, 15 insertions, 15 deletions
diff --git a/etc/dict.lua b/etc/dict.lua index 683cb45..c620cc4 100644 --- a/etc/dict.lua +++ b/etc/dict.lua | |||
@@ -17,13 +17,13 @@ while 1 do | |||
17 | if w=="=" then | 17 | if w=="=" then |
18 | w=read"*l" | 18 | w=read"*l" |
19 | verbose(">>>",w,"\n") | 19 | verbose(">>>",w,"\n") |
20 | send(s,w,"\r\n") | 20 | s:send(w,"\r\n") |
21 | else | 21 | else |
22 | verbose(">>> looking up `",w,"'\n") | 22 | verbose(">>> looking up `",w,"'\n") |
23 | send(s,"DEFINE wn ",w,"\r\n") | 23 | s:send("DEFINE wn ",w,"\r\n") |
24 | end | 24 | end |
25 | while 1 do | 25 | while 1 do |
26 | local l=receive(s) | 26 | local l=s:receive() |
27 | if l==nil then break end | 27 | if l==nil then break end |
28 | if strfind(l,"^[0-9]") then | 28 | if strfind(l,"^[0-9]") then |
29 | write("<<< ",l,"\n") | 29 | write("<<< ",l,"\n") |
@@ -34,6 +34,6 @@ while 1 do | |||
34 | end | 34 | end |
35 | end | 35 | end |
36 | 36 | ||
37 | send(s,"QUIT\r\n") | 37 | s:send("QUIT\r\n") |
38 | verbose("<<< ",receive(s),"\n") | 38 | verbose("<<< ",s:receive(),"\n") |
39 | close(s) | 39 | s:close() |
diff --git a/samples/echoclnt.lua b/samples/echoclnt.lua index d1c56c7..043b2f0 100644 --- a/samples/echoclnt.lua +++ b/samples/echoclnt.lua | |||
@@ -7,15 +7,15 @@ end | |||
7 | host = toip(host) | 7 | host = toip(host) |
8 | udp, err = udpsocket() | 8 | udp, err = udpsocket() |
9 | if not udp then print(err) exit() end | 9 | if not udp then print(err) exit() end |
10 | err = setpeername(udp, host, port) | 10 | err = udp:setpeername(host, port) |
11 | if err then print(err) exit() end | 11 | if err then print(err) exit() end |
12 | print("Using host '" ..host.. "' and port " ..port.. "...") | 12 | print("Using host '" ..host.. "' and port " .. port .. "...") |
13 | while 1 do | 13 | while 1 do |
14 | line = read() | 14 | line = read() |
15 | if not line then exit() end | 15 | if not line then exit() end |
16 | err = send(udp, line) | 16 | err = udp:send(line) |
17 | if err then print(err) exit() end | 17 | if err then print(err) exit() end |
18 | dgram, err = receive(udp) | 18 | dgram, err = udp:receive() |
19 | if not dgram then print(err) exit() end | 19 | if not dgram then print(err) exit() end |
20 | print(dgram) | 20 | print(dgram) |
21 | end | 21 | end |
diff --git a/samples/echosrvr.lua b/samples/echosrvr.lua index fe7da06..330f9e6 100644 --- a/samples/echosrvr.lua +++ b/samples/echosrvr.lua | |||
@@ -7,16 +7,16 @@ end | |||
7 | print("Binding to host '" ..host.. "' and port " ..port.. "...") | 7 | print("Binding to host '" ..host.. "' and port " ..port.. "...") |
8 | udp, err = udpsocket() | 8 | udp, err = udpsocket() |
9 | if not udp then print(err) exit() end | 9 | if not udp then print(err) exit() end |
10 | err = setsockname(udp, host, port) | 10 | err = udp:setsockname(host, port) |
11 | if err then print(err) exit() end | 11 | if err then print(err) exit() end |
12 | timeout(udp, 5) | 12 | udp:timeout(5) |
13 | ip, port = getsockname(udp) | 13 | ip, port = udp:getsockname() |
14 | print("Waiting packets on " .. ip .. ":" .. port .. "...") | 14 | print("Waiting packets on " .. ip .. ":" .. port .. "...") |
15 | while 1 do | 15 | while 1 do |
16 | dgram, ip, port = receivefrom(udp) | 16 | dgram, ip, port = udp:receivefrom() |
17 | if not dgram then print(ip) | 17 | if not dgram then print(ip) |
18 | else | 18 | else |
19 | print("Echoing from " .. ip .. ":" .. port) | 19 | print("Echoing from " .. ip .. ":" .. port) |
20 | sendto(udp, dgram, ip, port) | 20 | udp:sendto(dgram, ip, port) |
21 | end | 21 | end |
22 | end | 22 | end |