Changed send function.
This commit is contained in:
parent
e4e2223cff
commit
c8b402e004
8 changed files with 118 additions and 70 deletions
|
@ -1,29 +1,14 @@
|
|||
socket = require"socket"
|
||||
|
||||
host = host or "localhost"
|
||||
port = port or "8080"
|
||||
|
||||
server, error = socket.bind(host, port)
|
||||
if not server then print("server: " .. tostring(error)) os.exit() end
|
||||
ack = "\n"
|
||||
socket = require("socket");
|
||||
host = host or "localhost";
|
||||
port = port or "8080";
|
||||
server = assert(socket.bind(host, port));
|
||||
ack = "\n";
|
||||
while 1 do
|
||||
print("server: waiting for client connection...");
|
||||
control, error = server:accept()
|
||||
assert(control, error)
|
||||
-- control:setoption("nodelay", true)
|
||||
control = assert(server:accept());
|
||||
while 1 do
|
||||
command, error = control:receive()
|
||||
if error then
|
||||
control:close()
|
||||
print("server: closing connection...")
|
||||
break
|
||||
end
|
||||
sent, error = control:send(ack)
|
||||
if error then
|
||||
control:close()
|
||||
print("server: closing connection...")
|
||||
break
|
||||
end
|
||||
(loadstring(command))()
|
||||
command = assert(control:receive());
|
||||
assert(control:send(ack));
|
||||
(loadstring(command))();
|
||||
end
|
||||
end
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue