summaryrefslogtreecommitdiff
path: root/Build/source/texk/web2c/luatexdir/luasocket/samples/talker.lua
diff options
context:
space:
mode:
Diffstat (limited to 'Build/source/texk/web2c/luatexdir/luasocket/samples/talker.lua')
-rw-r--r--Build/source/texk/web2c/luatexdir/luasocket/samples/talker.lua20
1 files changed, 20 insertions, 0 deletions
diff --git a/Build/source/texk/web2c/luatexdir/luasocket/samples/talker.lua b/Build/source/texk/web2c/luatexdir/luasocket/samples/talker.lua
new file mode 100644
index 00000000000..d5a36cbe256
--- /dev/null
+++ b/Build/source/texk/web2c/luatexdir/luasocket/samples/talker.lua
@@ -0,0 +1,20 @@
+-----------------------------------------------------------------------------
+-- TCP sample: Little program to send text lines to a given host/port
+-- LuaSocket sample files
+-- Author: Diego Nehab
+-----------------------------------------------------------------------------
+local socket = require("socket")
+host = host or "localhost"
+port = port or 8080
+if arg then
+ host = arg[1] or host
+ port = arg[2] or port
+end
+print("Attempting connection to host '" ..host.. "' and port " ..port.. "...")
+c = assert(socket.connect(host, port))
+print("Connected! Please type stuff (empty line to stop):")
+l = io.read()
+while l and l ~= "" and not e do
+ assert(c:send(l .. "\n"))
+ l = io.read()
+end