beta-0.89.2
[luatex.git] / source / texk / web2c / luatexdir / luasocket / samples / talker.lua
blobd5a36cbe2564ae3cbb42160e9a9139007dcaeddb
1 -----------------------------------------------------------------------------
2 -- TCP sample: Little program to send text lines to a given host/port
3 -- LuaSocket sample files
4 -- Author: Diego Nehab
5 -----------------------------------------------------------------------------
6 local socket = require("socket")
7 host = host or "localhost"
8 port = port or 8080
9 if arg then
10 host = arg[1] or host
11 port = arg[2] or port
12 end
13 print("Attempting connection to host '" ..host.. "' and port " ..port.. "...")
14 c = assert(socket.connect(host, port))
15 print("Connected! Please type stuff (empty line to stop):")
16 l = io.read()
17 while l and l ~= "" and not e do
18 assert(c:send(l .. "\n"))
19 l = io.read()
20 end