mirror of
https://github.com/lunarmodules/luasocket.git
synced 2025-07-13 06:04:31 +02:00
Fine tuning the "require" business.
This commit is contained in:
@ -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
|
||||
|
Reference in New Issue
Block a user