aboutsummaryrefslogtreecommitdiff
path: root/samples/talker.lua
diff options
context:
space:
mode:
authorDiego Nehab <diego@tecgraf.puc-rio.br>2004-05-30 21:36:22 +0000
committerDiego Nehab <diego@tecgraf.puc-rio.br>2004-05-30 21:36:22 +0000
commit5ca1049ab47f3f9ff9157f71af9072f04a637500 (patch)
tree24fcb14f2890900a4a709312ab25bfc2c14a3939 /samples/talker.lua
parentc23240726e3044e3eaa32a82a999b754c08bc183 (diff)
downloadluasocket-5ca1049ab47f3f9ff9157f71af9072f04a637500.tar.gz
luasocket-5ca1049ab47f3f9ff9157f71af9072f04a637500.tar.bz2
luasocket-5ca1049ab47f3f9ff9157f71af9072f04a637500.zip
Fine tuning the "require" business.
Diffstat (limited to 'samples/talker.lua')
-rw-r--r--samples/talker.lua13
1 files changed, 3 insertions, 10 deletions
diff --git a/samples/talker.lua b/samples/talker.lua
index 1b0652f..94d2133 100644
--- a/samples/talker.lua
+++ b/samples/talker.lua
@@ -4,6 +4,7 @@
4-- Author: Diego Nehab 4-- Author: Diego Nehab
5-- RCS ID: $Id$ 5-- RCS ID: $Id$
6----------------------------------------------------------------------------- 6-----------------------------------------------------------------------------
7require("socket")
7host = host or "localhost" 8host = host or "localhost"
8port = port or 8080 9port = port or 8080
9if arg then 10if arg then
@@ -11,18 +12,10 @@ if arg then
11 port = arg[2] or port 12 port = arg[2] or port
12end 13end
13print("Attempting connection to host '" ..host.. "' and port " ..port.. "...") 14print("Attempting connection to host '" ..host.. "' and port " ..port.. "...")
14c, e = socket.connect(host, port) 15c = socket.try(socket.connect(host, port))
15if not c then
16 print(e)
17 os.exit()
18end
19print("Connected! Please type stuff (empty line to stop):") 16print("Connected! Please type stuff (empty line to stop):")
20l = io.read() 17l = io.read()
21while l and l ~= "" and not e do 18while l and l ~= "" and not e do
22 t, e = c:send(l, "\n") 19 socket.try(c:send(l, "\n"))
23 if e then
24 print(e)
25 os.exit()
26 end
27 l = io.read() 20 l = io.read()
28end 21end