comparison samples/listener.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 -- TCP sample: Little program to dump lines received at a given port
3 -- LuaSocket sample files
4 -- Author: Diego Nehab
5 -- RCS ID: $Id: listener.lua,v 1.11 2005/01/02 22:44:00 diego Exp $
6 -----------------------------------------------------------------------------
7 local socket = require("socket")
8 host = host or "*"
9 port = port or 8080
10 if arg then
11 host = arg[1] or host
12 port = arg[2] or port
13 end
14 print("Binding to host '" ..host.. "' and port " ..port.. "...")
15 s = assert(socket.bind(host, port))
16 i, p = s:getsockname()
17 assert(i, p)
18 print("Waiting connection from talker on " .. i .. ":" .. p .. "...")
19 c = assert(s:accept())
20 print("Connected. Here is the stuff:")
21 l, e = c:receive()
22 while not e do
23 print(l)
24 l, e = c:receive()
25 end
26 print(e)