From e4e2223cff658a7016724a625ebbd3dacb92a8f9 Mon Sep 17 00:00:00 2001 From: Diego Nehab Date: Fri, 16 Jul 2004 06:48:48 +0000 Subject: Fixed a bunch of stuff. Added mike's patches. --- samples/listener.lua | 50 +++++++++++++++++++++++++------------------------- 1 file changed, 25 insertions(+), 25 deletions(-) (limited to 'samples') diff --git a/samples/listener.lua b/samples/listener.lua index b2f7a7e..65c6501 100644 --- a/samples/listener.lua +++ b/samples/listener.lua @@ -1,25 +1,25 @@ ------------------------------------------------------------------------------ --- TCP sample: Little program to dump lines received at a given port --- LuaSocket sample files --- Author: Diego Nehab --- RCS ID: $Id$ ------------------------------------------------------------------------------ -local socket = require("socket") -host = host or "*" -port = port or 8080 -if arg then - host = arg[1] or host - port = arg[2] or port -end -print("Binding to host '" ..host.. "' and port " ..port.. "...") -s = socket.try(socket.bind(host, port)) -i, p = socket.try(s:getsockname()) -print("Waiting connection from talker on " .. i .. ":" .. p .. "...") -c = socket.try(s:accept()) -print("Connected. Here is the stuff:") -l, e = c:receive() -while not e do - print(l) - l, e = c:receive() -end -print(e) +----------------------------------------------------------------------------- +-- TCP sample: Little program to dump lines received at a given port +-- LuaSocket sample files +-- Author: Diego Nehab +-- RCS ID: $Id$ +----------------------------------------------------------------------------- +local socket = require("socket") +host = host or "*" +port = port or 8080 +if arg then + host = arg[1] or host + port = arg[2] or port +end +print("Binding to host '" ..host.. "' and port " ..port.. "...") +s = socket.try(socket.bind(host, port)) +i, p = socket.try(s:getsockname()) +print("Waiting connection from talker on " .. i .. ":" .. p .. "...") +c = socket.try(s:accept()) +print("Connected. Here is the stuff:") +l, e = c:receive() +while not e do + print(l) + l, e = c:receive() +end +print(e) -- cgit v1.2.3-55-g6feb