diff options
Diffstat (limited to 'samples/talker.lua')
-rw-r--r-- | samples/talker.lua | 22 |
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 @@ | |||
1 | host = "localhost" | ||
2 | port = 8080 | ||
3 | if arg then | ||
4 | host = arg[1] or host | ||
5 | port = arg[2] or port | ||
6 | end | ||
7 | print("Attempting connection to host '" ..host.. "' and port " ..port.. "...") | ||
8 | c, e = connect(host, port) | ||
9 | if not c then | ||
10 | print(e) | ||
11 | exit() | ||
12 | end | ||
13 | print("Connected! Please type stuff (empty line to stop):") | ||
14 | l = read() | ||
15 | while 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() | ||
22 | end | ||