From ff0f488c97fe8b554b909a0057cebc4c860eac8f Mon Sep 17 00:00:00 2001 From: chai Date: Wed, 20 Oct 2021 13:40:34 +0800 Subject: +luasocket src --- ThirdParty/luasocket/samples/talker.lua | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) create mode 100644 ThirdParty/luasocket/samples/talker.lua (limited to 'ThirdParty/luasocket/samples/talker.lua') 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 -- cgit v1.1-26-g67d0