diff options
author | Diego Nehab <diego@tecgraf.puc-rio.br> | 2004-07-18 22:56:14 +0000 |
---|---|---|
committer | Diego Nehab <diego@tecgraf.puc-rio.br> | 2004-07-18 22:56:14 +0000 |
commit | c8b402e00442cd249397d4d33d2723a1f08a8108 (patch) | |
tree | d72a1ace55b42aa9d41c741fa2f757d92fad6592 /test/testsrvr.lua | |
parent | e4e2223cff658a7016724a625ebbd3dacb92a8f9 (diff) | |
download | luasocket-c8b402e00442cd249397d4d33d2723a1f08a8108.tar.gz luasocket-c8b402e00442cd249397d4d33d2723a1f08a8108.tar.bz2 luasocket-c8b402e00442cd249397d4d33d2723a1f08a8108.zip |
Changed send function.
Diffstat (limited to 'test/testsrvr.lua')
-rw-r--r-- | test/testsrvr.lua | 33 |
1 files changed, 9 insertions, 24 deletions
diff --git a/test/testsrvr.lua b/test/testsrvr.lua index 969f95b..23e3850 100644 --- a/test/testsrvr.lua +++ b/test/testsrvr.lua | |||
@@ -1,29 +1,14 @@ | |||
1 | socket = require"socket" | 1 | socket = require("socket"); |
2 | 2 | host = host or "localhost"; | |
3 | host = host or "localhost" | 3 | port = port or "8080"; |
4 | port = port or "8080" | 4 | server = assert(socket.bind(host, port)); |
5 | 5 | ack = "\n"; | |
6 | server, error = socket.bind(host, port) | ||
7 | if not server then print("server: " .. tostring(error)) os.exit() end | ||
8 | ack = "\n" | ||
9 | while 1 do | 6 | while 1 do |
10 | print("server: waiting for client connection..."); | 7 | print("server: waiting for client connection..."); |
11 | control, error = server:accept() | 8 | control = assert(server:accept()); |
12 | assert(control, error) | ||
13 | -- control:setoption("nodelay", true) | ||
14 | while 1 do | 9 | while 1 do |
15 | command, error = control:receive() | 10 | command = assert(control:receive()); |
16 | if error then | 11 | assert(control:send(ack)); |
17 | control:close() | 12 | (loadstring(command))(); |
18 | print("server: closing connection...") | ||
19 | break | ||
20 | end | ||
21 | sent, error = control:send(ack) | ||
22 | if error then | ||
23 | control:close() | ||
24 | print("server: closing connection...") | ||
25 | break | ||
26 | end | ||
27 | (loadstring(command))() | ||
28 | end | 13 | end |
29 | end | 14 | end |