From 5ca1049ab47f3f9ff9157f71af9072f04a637500 Mon Sep 17 00:00:00 2001 From: Diego Nehab Date: Sun, 30 May 2004 21:36:22 +0000 Subject: Fine tuning the "require" business. --- samples/talker.lua | 13 +++---------- 1 file changed, 3 insertions(+), 10 deletions(-) (limited to 'samples/talker.lua') 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 @@ -- Author: Diego Nehab -- RCS ID: $Id$ ----------------------------------------------------------------------------- +require("socket") host = host or "localhost" port = port or 8080 if arg then @@ -11,18 +12,10 @@ if arg then port = arg[2] or port end print("Attempting connection to host '" ..host.. "' and port " ..port.. "...") -c, e = socket.connect(host, port) -if not c then - print(e) - os.exit() -end +c = socket.try(socket.connect(host, port)) print("Connected! Please type stuff (empty line to stop):") l = io.read() while l and l ~= "" and not e do - t, e = c:send(l, "\n") - if e then - print(e) - os.exit() - end + socket.try(c:send(l, "\n")) l = io.read() end -- cgit v1.2.3-55-g6feb