Blame samples/daytimeclnt.lua

Packit b53373
-----------------------------------------------------------------------------
Packit b53373
-- UDP sample: daytime protocol client
Packit b53373
-- LuaSocket sample files
Packit b53373
-- Author: Diego Nehab
Packit b53373
-----------------------------------------------------------------------------
Packit b53373
local socket = require"socket"
Packit b53373
host = host or "127.0.0.1"
Packit b53373
port = port or 13
Packit b53373
if arg then
Packit b53373
    host = arg[1] or host
Packit b53373
    port = arg[2] or port
Packit b53373
end
Packit b53373
host = socket.dns.toip(host)
Packit b53373
udp = socket.udp()
Packit b53373
print("Using host '" ..host.. "' and port " ..port.. "...")
Packit b53373
udp:setpeername(host, port)
Packit b53373
udp:settimeout(3)
Packit b53373
sent, err = udp:send("anything")
Packit b53373
if err then print(err) os.exit() end
Packit b53373
dgram, err = udp:receive()
Packit b53373
if not dgram then print(err) os.exit() end
Packit b53373
io.write(dgram)