mirror of
https://github.com/lunarmodules/luasocket.git
synced 2024-11-08 14:28:21 +01:00
25 lines
640 B
Lua
25 lines
640 B
Lua
HOST = HOST or "localhost"
|
|
PORT = PORT or "8080"
|
|
|
|
server, error = bind(HOST, PORT)
|
|
if not server then print("server: " .. tostring(error)) exit() end
|
|
while 1 do
|
|
print("server: waiting for client connection...");
|
|
control = server:accept()
|
|
while 1 do
|
|
command, error = control:receive()
|
|
if error then
|
|
control:close()
|
|
print("server: closing connection...")
|
|
break
|
|
end
|
|
error = control:send("\n")
|
|
if error then
|
|
control:close()
|
|
print("server: closing connection...")
|
|
break
|
|
end
|
|
dostring(command)
|
|
end
|
|
end
|