diff options
author | dimitri staessens <[email protected]> | 2017-03-31 09:58:23 +0000 |
---|---|---|
committer | Sander Vrijders <[email protected]> | 2017-03-31 09:58:23 +0000 |
commit | ad01a7fd0b6cd798b2d5a2901ae8499b25360707 (patch) | |
tree | 16b6fd66c3fe93d178e10a137179923b513851f9 /src/tools/echo/echo_server.c | |
parent | 5f79a21b80e68ba59616f0fa431287c3e94c43cf (diff) | |
parent | 7ba0fd0ce19244745c8d2512ce8a003783d914a7 (diff) | |
download | ouroboros-ad01a7fd0b6cd798b2d5a2901ae8499b25360707.tar.gz ouroboros-ad01a7fd0b6cd798b2d5a2901ae8499b25360707.zip |
Merged in dstaesse/ouroboros/be-new-api (pull request #439)
lib: Revise flow allocation API
Diffstat (limited to 'src/tools/echo/echo_server.c')
-rw-r--r-- | src/tools/echo/echo_server.c | 22 |
1 files changed, 8 insertions, 14 deletions
diff --git a/src/tools/echo/echo_server.c b/src/tools/echo/echo_server.c index aa136485..771155f4 100644 --- a/src/tools/echo/echo_server.c +++ b/src/tools/echo/echo_server.c @@ -37,7 +37,7 @@ void shutdown_server(int signo) int server_main(void) { - int client_fd = 0; + int fd = 0; char buf[BUF_SIZE]; ssize_t count = 0; qosspec_t qs; @@ -51,36 +51,30 @@ int server_main(void) } while (true) { - client_fd = flow_accept(&qs); - if (client_fd < 0) { + fd = flow_accept(&qs, NULL); + if (fd < 0) { printf("Failed to accept flow.\n"); break; } printf("New flow.\n"); - if (flow_alloc_resp(client_fd, 0)) { - printf("Failed to give an allocate response.\n"); - flow_dealloc(client_fd); - continue; - } - - count = flow_read(client_fd, &buf, BUF_SIZE); + count = flow_read(fd, &buf, BUF_SIZE); if (count < 0) { printf("Failed to read SDU.\n"); - flow_dealloc(client_fd); + flow_dealloc(fd); continue; } printf("Message from client is %.*s.\n", (int) count, buf); - if (flow_write(client_fd, buf, count) == -1) { + if (flow_write(fd, buf, count) == -1) { printf("Failed to write SDU.\n"); - flow_dealloc(client_fd); + flow_dealloc(fd); continue; } - flow_dealloc(client_fd); + flow_dealloc(fd); } return 0; |