Mercurial > luasocket
comparison samples/talker.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 send text lines to a given host/port | |
3 -- LuaSocket sample files | |
4 -- Author: Diego Nehab | |
5 -- RCS ID: $Id: talker.lua,v 1.9 2005/01/02 22:44:00 diego Exp $ | |
6 ----------------------------------------------------------------------------- | |
7 local socket = require("socket") | |
8 host = host or "localhost" | |
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("Attempting connection to host '" ..host.. "' and port " ..port.. "...") | |
15 c = assert(socket.connect(host, port)) | |
16 print("Connected! Please type stuff (empty line to stop):") | |
17 l = io.read() | |
18 while l and l ~= "" and not e do | |
19 assert(c:send(l .. "\n")) | |
20 l = io.read() | |
21 end |