2004-07-18 15:56:14 -07:00
|
|
|
socket = require("socket");
|
|
|
|
host = host or "localhost";
|
2004-11-26 23:58:04 -08:00
|
|
|
port = port or "8383";
|
2004-07-18 15:56:14 -07:00
|
|
|
server = assert(socket.bind(host, port));
|
|
|
|
ack = "\n";
|
2001-01-25 14:00:18 -08:00
|
|
|
while 1 do
|
2002-07-08 14:56:01 -07:00
|
|
|
print("server: waiting for client connection...");
|
2004-07-18 15:56:14 -07:00
|
|
|
control = assert(server:accept());
|
2015-08-22 15:52:01 -07:00
|
|
|
while 1 do
|
2011-08-08 16:23:06 -07:00
|
|
|
command, emsg = control:receive();
|
|
|
|
if emsg == "closed" then
|
|
|
|
control:close()
|
|
|
|
break
|
|
|
|
end
|
|
|
|
assert(command, emsg)
|
2004-07-18 15:56:14 -07:00
|
|
|
assert(control:send(ack));
|
2005-02-08 02:01:01 -08:00
|
|
|
print(command);
|
2012-04-29 11:46:35 -07:00
|
|
|
((loadstring or load)(command))();
|
2002-07-08 14:56:01 -07:00
|
|
|
end
|
2001-01-25 14:00:18 -08:00
|
|
|
end
|