mirror of
https://github.com/lunarmodules/luasocket.git
synced 2025-07-13 06:04:31 +02:00
Bug feioso no UDP e possivelmente no TCP também.
This commit is contained in:
@ -4,6 +4,7 @@
|
||||
-- Author: Diego Nehab
|
||||
-- RCS ID: $Id$
|
||||
-----------------------------------------------------------------------------
|
||||
require"luasocket"
|
||||
host = host or "localhost"
|
||||
port = port or 7
|
||||
if arg then
|
||||
@ -11,17 +12,13 @@ if arg then
|
||||
port = arg[2] or port
|
||||
end
|
||||
host = socket.dns.toip(host)
|
||||
udp, err = socket.udp()
|
||||
assert(udp, err)
|
||||
ret, err = udp:setpeername(host, port)
|
||||
assert(ret, err)
|
||||
print("Using host '" ..host.. "' and port " .. port .. "...")
|
||||
udp = socket.try(socket.udp())
|
||||
socket.try(udp:setpeername(host, port))
|
||||
print("Using remote host '" ..host.. "' and port " .. port .. "...")
|
||||
while 1 do
|
||||
line = io.read()
|
||||
if not line then 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
|
||||
socket.try(udp:send(line))
|
||||
dgram = socket.try(udp:receive())
|
||||
print(dgram)
|
||||
end
|
||||
|
Reference in New Issue
Block a user