luasocket/test/testsrvr.lua

25 lines
640 B
Lua
Raw Normal View History

2002-07-08 23:56:01 +02:00
HOST = HOST or "localhost"
PORT = PORT or "8080"
2001-01-25 23:00:18 +01:00
2002-07-08 23:56:01 +02:00
server, error = bind(HOST, PORT)
if not server then print("server: " .. tostring(error)) exit() end
2001-01-25 23:00:18 +01:00
while 1 do
2002-07-08 23:56:01 +02:00
print("server: waiting for client connection...");
control = server:accept()
while 1 do
command, error = control:receive()
if error then
control:close()
print("server: closing connection...")
break
end
error = control:send("\n")
if error then
control:close()
print("server: closing connection...")
break
end
dostring(command)
end
2001-01-25 23:00:18 +01:00
end