summaryrefslogtreecommitdiff
path: root/ThirdParty/luasocket/samples/talker.lua
diff options
context:
space:
mode:
authorchai <chaifix@163.com>2021-10-20 13:40:34 +0800
committerchai <chaifix@163.com>2021-10-20 13:40:34 +0800
commitff0f488c97fe8b554b909a0057cebc4c860eac8f (patch)
tree4e47262b52ffce7e9cfeaaeeab46371243bcaa78 /ThirdParty/luasocket/samples/talker.lua
parentdde719dd575090b36aaa3ad85bb3cabf33f36c5a (diff)
+luasocket src
Diffstat (limited to 'ThirdParty/luasocket/samples/talker.lua')
-rw-r--r--ThirdParty/luasocket/samples/talker.lua20
1 files changed, 20 insertions, 0 deletions
diff --git a/ThirdParty/luasocket/samples/talker.lua b/ThirdParty/luasocket/samples/talker.lua
new file mode 100644
index 0000000..d5a36cb
--- /dev/null
+++ b/ThirdParty/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