2003-03-28 22:08:50 +01:00
|
|
|
host = host or "localhost"
|
|
|
|
port = port or "8080"
|
2001-01-25 23:00:18 +01:00
|
|
|
|
2003-03-28 22:08:50 +01:00
|
|
|
server, error = socket.bind(host, port)
|
2002-12-03 08:20:34 +01:00
|
|
|
if not server then print("server: " .. tostring(error)) os.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
|
2003-05-25 03:54:13 +02:00
|
|
|
sent, error = control:send("\n")
|
2002-07-08 23:56:01 +02:00
|
|
|
if error then
|
|
|
|
control:close()
|
|
|
|
print("server: closing connection...")
|
|
|
|
break
|
|
|
|
end
|
2003-05-25 03:54:13 +02:00
|
|
|
print(command);
|
2002-12-03 08:20:34 +01:00
|
|
|
(loadstring(command))()
|
2002-07-08 23:56:01 +02:00
|
|
|
end
|
2001-01-25 23:00:18 +01:00
|
|
|
end
|