aboutsummaryrefslogtreecommitdiff
path: root/samples/listener.lua
diff options
context:
space:
mode:
authorDiego Nehab <diego@tecgraf.puc-rio.br>2000-12-29 22:15:09 +0000
committerDiego Nehab <diego@tecgraf.puc-rio.br>2000-12-29 22:15:09 +0000
commit17c4d1c30544f0ed638879835f179ada96249868 (patch)
tree46ca8042ba8fda147f56af61e26ec2ceec41f614 /samples/listener.lua
parent6f9d15b66027cef58441549f8ac0603ca42da0ac (diff)
downloadluasocket-17c4d1c30544f0ed638879835f179ada96249868.tar.gz
luasocket-17c4d1c30544f0ed638879835f179ada96249868.tar.bz2
luasocket-17c4d1c30544f0ed638879835f179ada96249868.zip
Initial revision
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)