aboutsummaryrefslogtreecommitdiff
path: root/samples
diff options
context:
space:
mode:
Diffstat (limited to 'samples')
-rw-r--r--samples/echoclnt.lua8
-rw-r--r--samples/echosrvr.lua10
2 files changed, 9 insertions, 9 deletions
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
7host = toip(host) 7host = toip(host)
8udp, err = udpsocket() 8udp, err = udpsocket()
9if not udp then print(err) exit() end 9if not udp then print(err) exit() end
10err = setpeername(udp, host, port) 10err = udp:setpeername(host, port)
11if err then print(err) exit() end 11if err then print(err) exit() end
12print("Using host '" ..host.. "' and port " ..port.. "...") 12print("Using host '" ..host.. "' and port " .. port .. "...")
13while 1 do 13while 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)
21end 21end
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
7print("Binding to host '" ..host.. "' and port " ..port.. "...") 7print("Binding to host '" ..host.. "' and port " ..port.. "...")
8udp, err = udpsocket() 8udp, err = udpsocket()
9if not udp then print(err) exit() end 9if not udp then print(err) exit() end
10err = setsockname(udp, host, port) 10err = udp:setsockname(host, port)
11if err then print(err) exit() end 11if err then print(err) exit() end
12timeout(udp, 5) 12udp:timeout(5)
13ip, port = getsockname(udp) 13ip, port = udp:getsockname()
14print("Waiting packets on " .. ip .. ":" .. port .. "...") 14print("Waiting packets on " .. ip .. ":" .. port .. "...")
15while 1 do 15while 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
22end 22end