comparison samples/daytimeclnt.lua @ 0:4b915342e2a8

LuaSocket 2.0.2 + CMake build description.
author Eric Wing <ewing . public |-at-| gmail . com>
date Tue, 26 Aug 2008 18:40:01 -0700
parents
children
comparison
equal deleted inserted replaced
-1:000000000000 0:4b915342e2a8
1 -----------------------------------------------------------------------------
2 -- UDP sample: daytime protocol client
3 -- LuaSocket sample files
4 -- Author: Diego Nehab
5 -- RCS ID: $Id: daytimeclnt.lua,v 1.11 2004/06/21 06:07:57 diego Exp $
6 -----------------------------------------------------------------------------
7 local socket = require"socket"
8 host = host or "127.0.0.1"
9 port = port or 13
10 if arg then
11 host = arg[1] or host
12 port = arg[2] or port
13 end
14 host = socket.dns.toip(host)
15 udp = socket.udp()
16 print("Using host '" ..host.. "' and port " ..port.. "...")
17 udp:setpeername(host, port)
18 udp:settimeout(3)
19 sent, err = udp:send("anything")
20 if err then print(err) os.exit() end
21 dgram, err = udp:receive()
22 if not dgram then print(err) os.exit() end
23 io.write(dgram)