aboutsummaryrefslogtreecommitdiff
path: root/samples/listener.lua
diff options
context:
space:
mode:
Diffstat (limited to 'samples/listener.lua')
-rw-r--r--samples/listener.lua25
1 files changed, 25 insertions, 0 deletions
diff --git a/samples/listener.lua b/samples/listener.lua
new file mode 100644
index 0000000..a47d9a3
--- /dev/null
+++ b/samples/listener.lua
@@ -0,0 +1,25 @@
1host = "localhost"
2port = 8080
3if arg then
4 host = arg[1] or host
5 port = arg[2] or port
6end
7print("Binding to host '" ..host.. "' and port " ..port.. "...")
8s, i, p, e = bind(host, port)
9if not s then
10 print(e)
11 exit()
12end
13print("Waiting connection from talker on " .. i .. ":" .. p .. "...")
14c, e = s:accept()
15if not c then
16 print(e)
17 exit()
18end
19print("Connected. Here is the stuff:")
20l, e = c:receive()
21while not e do
22 print(l)
23 l, e = c:receive()
24end
25print(e)