luasocket/test/testsrvr.lua
Sam Roberts 3b19f2a7ed testsrvr asserts when test finishes successfully.
When the test client finishes, the test server asserts with a "closed" message.
After looking carefully at this, I think the tests are running
successfully and passing. Since it appears to be a test failure, I
modified the server to allow the client to close the control connection.
2012-04-11 13:45:59 -07:00

21 lines
522 B
Lua

socket = require("socket");
host = host or "localhost";
port = port or "8383";
server = assert(socket.bind(host, port));
ack = "\n";
while 1 do
print("server: waiting for client connection...");
control = assert(server:accept());
while 1 do
command, emsg = control:receive();
if emsg == "closed" then
control:close()
break
end
assert(command, emsg)
assert(control:send(ack));
print(command);
(loadstring(command))();
end
end