diff options
Diffstat (limited to 'src/tools/echo')
| -rw-r--r-- | src/tools/echo/echo_client.c | 12 | ||||
| -rw-r--r-- | src/tools/echo/echo_server.c | 22 | 
2 files changed, 10 insertions, 24 deletions
| diff --git a/src/tools/echo/echo_client.c b/src/tools/echo/echo_client.c index f84de73a..5ec2051f 100644 --- a/src/tools/echo/echo_client.c +++ b/src/tools/echo/echo_client.c @@ -26,25 +26,17 @@  int client_main(void)  {          int fd = 0; -        int result = 0;          char buf[BUF_SIZE];          char * message  = "Client says hi!";          ssize_t count = 0; -        fd = flow_alloc("echo", NULL); +        fd = flow_alloc("echo", NULL, NULL);          if (fd < 0) {                  printf("Failed to allocate flow.\n");                  return -1;          } -        result = flow_alloc_res(fd); -        if (result < 0) { -                printf("Flow allocation refused.\n"); -                flow_dealloc(fd); -                return -1; -        } - -        if (flow_write(fd, message, strlen(message) + 1) == -1) { +        if (flow_write(fd, message, strlen(message) + 1) < 0) {                  printf("Failed to write SDU.\n");                  flow_dealloc(fd);                  return -1; 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; | 
