File: testsrvr.lua

package info (click to toggle)
luasocket 3.1.0-2
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 2,264 kB
  • sloc: ansic: 4,845; makefile: 337; sh: 116
file content (20 lines) | stat: -rw-r--r-- 525 bytes parent folder | download | duplicates (11)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
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 or load)(command))();
    end
end