diff --git a/server/src/node.c b/server/src/node.c index c56a246d7..2a27c82c4 100644 --- a/server/src/node.c +++ b/server/src/node.c @@ -7,6 +7,7 @@ #include #include #include +#include #include "config.h" #include "cfg.h" @@ -39,6 +40,13 @@ int node_connect(struct node *n) if (bind(n->sd, (struct sockaddr *) &n->local, sizeof(struct sockaddr_in))) perror("Failed to bind to socket"); + debug(1, " We listen for node '%s' at %s:%u", + n->name, inet_ntoa(n->local.sin_addr), + ntohs(n->local.sin_port)); + debug(1, " We sent to node '%s' at %s:%u", + n->name, inet_ntoa(n->remote.sin_addr), + ntohs(n->remote.sin_port)); + return 0; } diff --git a/server/src/receive.c b/server/src/receive.c index 700a30850..d3d0d704c 100644 --- a/server/src/receive.c +++ b/server/src/receive.c @@ -56,11 +56,11 @@ int main(int argc, char *argv[]) if (resolve_addr(argv[1], &n.local, 0)) error("Failed to resolve local address: %s", argv[1]); + node_connect(&n); + /* Print header */ fprintf(stderr, "# %-6s %-8s %-12s\n", "dev_id", "seq_no", "data"); - node_connect(&n); - while (1) { msg_recv(&m, &n); diff --git a/server/src/send.c b/server/src/send.c index 4fa1aa576..5c74b3106 100644 --- a/server/src/send.c +++ b/server/src/send.c @@ -68,11 +68,7 @@ int main(int argc, char *argv[]) n.local.sin_port = 0; /* random port */ } - debug(1, "We listen at %s:%u", inet_ntoa(n.local.sin_addr), ntohs(n.local.sin_port)); - debug(1, "We sent to %s:%u", inet_ntoa(n.remote.sin_addr), ntohs(n.remote.sin_port)); - - if (node_connect(&n)) - error("Failed to connect node"); + node_connect(&n); while (!feof(stdin)) { msg_fscan(stdin, &m); diff --git a/server/src/server.c b/server/src/server.c index 7b5a98815..c871059e2 100644 --- a/server/src/server.c +++ b/server/src/server.c @@ -6,14 +6,10 @@ #include #include -#include #include #include #include -#include -#include -#include #include #include "config.h" @@ -81,12 +77,6 @@ static void start() node_connect(n); - debug(1, " We listen for node '%s' at %s:%u", - n->name, inet_ntoa(n->local.sin_addr), - ntohs(n->local.sin_port)); - debug(1, " We sent to node '%s' at %s:%u", - n->name, inet_ntoa(n->remote.sin_addr), - ntohs(n->remote.sin_port)); } /* Start on thread per path for asynchronous processing */ diff --git a/server/src/test.c b/server/src/test.c index b67cd126d..6ec182c59 100644 --- a/server/src/test.c +++ b/server/src/test.c @@ -66,9 +66,6 @@ int main(int argc, char *argv[]) node_connect(&n); - debug(1, "We listen at %s:%u", inet_ntoa(n.local.sin_addr), ntohs(n.local.sin_port)); - debug(1, "We sent to %s:%u", inet_ntoa(n.remote.sin_addr), ntohs(n.remote.sin_port)); - if (!strcmp(argv[1], "rtt")) { struct msg m = MSG_INIT(sizeof(struct timespec) / sizeof(float)); struct timespec *ts1 = (struct timespec *) &m.data;