2004-07-19 00:56:14 +02:00
|
|
|
socket = require("socket");
|
|
|
|
host = host or "localhost";
|
2004-11-27 08:58:04 +01:00
|
|
|
port = port or "8383";
|
2004-07-19 00:56:14 +02:00
|
|
|
server = assert(socket.bind(host, port));
|
|
|
|
ack = "\n";
|
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...");
|
2004-07-19 00:56:14 +02:00
|
|
|
control = assert(server:accept());
|
2015-08-23 00:52:01 +02:00
|
|
|
while 1 do
|
2011-08-09 01:23:06 +02:00
|
|
|
command, emsg = control:receive();
|
|
|
|
if emsg == "closed" then
|
|
|
|
control:close()
|
|
|
|
break
|
|
|
|
end
|
|
|
|
assert(command, emsg)
|
2004-07-19 00:56:14 +02:00
|
|
|
assert(control:send(ack));
|
2005-02-08 11:01:01 +01:00
|
|
|
print(command);
|
2012-04-29 20:46:35 +02:00
|
|
|
((loadstring or load)(command))();
|
2002-07-08 23:56:01 +02:00
|
|
|
end
|
2001-01-25 23:00:18 +01:00
|
|
|
end
|