diff options
| author | Diego Nehab <diego@tecgraf.puc-rio.br> | 2004-05-30 21:36:22 +0000 |
|---|---|---|
| committer | Diego Nehab <diego@tecgraf.puc-rio.br> | 2004-05-30 21:36:22 +0000 |
| commit | 5ca1049ab47f3f9ff9157f71af9072f04a637500 (patch) | |
| tree | 24fcb14f2890900a4a709312ab25bfc2c14a3939 /samples/talker.lua | |
| parent | c23240726e3044e3eaa32a82a999b754c08bc183 (diff) | |
| download | luasocket-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.lua | 13 |
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 | ----------------------------------------------------------------------------- |
| 7 | require("socket") | ||
| 7 | host = host or "localhost" | 8 | host = host or "localhost" |
| 8 | port = port or 8080 | 9 | port = port or 8080 |
| 9 | if arg then | 10 | if arg then |
| @@ -11,18 +12,10 @@ if arg then | |||
| 11 | port = arg[2] or port | 12 | port = arg[2] or port |
| 12 | end | 13 | end |
| 13 | print("Attempting connection to host '" ..host.. "' and port " ..port.. "...") | 14 | print("Attempting connection to host '" ..host.. "' and port " ..port.. "...") |
| 14 | c, e = socket.connect(host, port) | 15 | c = socket.try(socket.connect(host, port)) |
| 15 | if not c then | ||
| 16 | print(e) | ||
| 17 | os.exit() | ||
| 18 | end | ||
| 19 | print("Connected! Please type stuff (empty line to stop):") | 16 | print("Connected! Please type stuff (empty line to stop):") |
| 20 | l = io.read() | 17 | l = io.read() |
| 21 | while l and l ~= "" and not e do | 18 | while 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() |
| 28 | end | 21 | end |
