aboutsummaryrefslogtreecommitdiff
path: root/samples/talker.lua
diff options
context:
space:
mode:
Diffstat (limited to 'samples/talker.lua')
-rw-r--r--samples/talker.lua22
1 files changed, 22 insertions, 0 deletions
diff --git a/samples/talker.lua b/samples/talker.lua
new file mode 100644
index 0000000..b3313e6
--- /dev/null
+++ b/samples/talker.lua
@@ -0,0 +1,22 @@
1host = "localhost"
2port = 8080
3if arg then
4 host = arg[1] or host
5 port = arg[2] or port
6end
7print("Attempting connection to host '" ..host.. "' and port " ..port.. "...")
8c, e = connect(host, port)
9if not c then
10 print(e)
11 exit()
12end
13print("Connected! Please type stuff (empty line to stop):")
14l = read()
15while l and l ~= "" and not e do
16 e = c:send(l, "\n")
17 if e then
18 print(e)
19 exit()
20 end
21 l = read()
22end