diff options
Diffstat (limited to 'test/testsrvr.lua')
| -rw-r--r-- | test/testsrvr.lua | 22 |
1 files changed, 11 insertions, 11 deletions
diff --git a/test/testsrvr.lua b/test/testsrvr.lua index d69b5ab..efa5991 100644 --- a/test/testsrvr.lua +++ b/test/testsrvr.lua | |||
| @@ -30,7 +30,7 @@ if not server then | |||
| 30 | exit(1) | 30 | exit(1) |
| 31 | end | 31 | end |
| 32 | print("server: waiting for control connection...") | 32 | print("server: waiting for control connection...") |
| 33 | control = accept(server) | 33 | control = server:accept() |
| 34 | print("server: control connection stablished!") | 34 | print("server: control connection stablished!") |
| 35 | 35 | ||
| 36 | ----------------------------------------------------------------------------- | 36 | ----------------------------------------------------------------------------- |
| @@ -42,7 +42,7 @@ print("server: control connection stablished!") | |||
| 42 | function execute_command(cmd, par) | 42 | function execute_command(cmd, par) |
| 43 | if cmd == CONNECT then | 43 | if cmd == CONNECT then |
| 44 | print("server: waiting for data connection...") | 44 | print("server: waiting for data connection...") |
| 45 | data = accept(server) | 45 | data = server:accept() |
| 46 | if not data then | 46 | if not data then |
| 47 | fail("server: unable to start data connection!") | 47 | fail("server: unable to start data connection!") |
| 48 | else | 48 | else |
| @@ -51,31 +51,31 @@ function execute_command(cmd, par) | |||
| 51 | elseif cmd == CLOSE then | 51 | elseif cmd == CLOSE then |
| 52 | print("server: closing connection with client...") | 52 | print("server: closing connection with client...") |
| 53 | if data then | 53 | if data then |
| 54 | close(data) | 54 | data:close() |
| 55 | data = nil | 55 | data = nil |
| 56 | end | 56 | end |
| 57 | elseif cmd == ECHO_LINE then | 57 | elseif cmd == ECHO_LINE then |
| 58 | str, err = receive(data) | 58 | str, err = data:receive() |
| 59 | if err then fail("server: " .. err) end | 59 | if err then fail("server: " .. err) end |
| 60 | err = send(data, str, "\n") | 60 | err = data:send(str, "\n") |
| 61 | if err then fail("server: " .. err) end | 61 | if err then fail("server: " .. err) end |
| 62 | elseif cmd == ECHO_BLOCK then | 62 | elseif cmd == ECHO_BLOCK then |
| 63 | str, err = receive(data, par) | 63 | str, err = data:receive(par) |
| 64 | print(format("server: received %d bytes", strlen(str))) | 64 | print(format("server: received %d bytes", strlen(str))) |
| 65 | if err then fail("server: " .. err) end | 65 | if err then fail("server: " .. err) end |
| 66 | print(format("server: sending %d bytes", strlen(str))) | 66 | print(format("server: sending %d bytes", strlen(str))) |
| 67 | err = send(data, str) | 67 | err = data:send(str) |
| 68 | if err then fail("server: " .. err) end | 68 | if err then fail("server: " .. err) end |
| 69 | elseif cmd == RECEIVE_BLOCK then | 69 | elseif cmd == RECEIVE_BLOCK then |
| 70 | str, err = receive(data, par) | 70 | str, err = data:receive(par) |
| 71 | print(format("server: received %d bytes", strlen(str))) | 71 | print(format("server: received %d bytes", strlen(str))) |
| 72 | elseif cmd == SEND_BLOCK then | 72 | elseif cmd == SEND_BLOCK then |
| 73 | print(format("server: sending %d bytes", strlen(str))) | 73 | print(format("server: sending %d bytes", strlen(str))) |
| 74 | err = send(data, str) | 74 | err = data:send(str) |
| 75 | elseif cmd == ECHO_TIMEOUT then | 75 | elseif cmd == ECHO_TIMEOUT then |
| 76 | str, err = receive(data, par) | 76 | str, err = data:receive(par) |
| 77 | if err then fail("server: " .. err) end | 77 | if err then fail("server: " .. err) end |
| 78 | err = send(data, str) | 78 | err = data:send(str) |
| 79 | if err then fail("server: " .. err) end | 79 | if err then fail("server: " .. err) end |
| 80 | elseif cmd == COMMAND then | 80 | elseif cmd == COMMAND then |
| 81 | cmd, par = get_command() | 81 | cmd, par = get_command() |
