From 210dafcaf6bdb0428ee20967a90ff9f8cc3d5199 Mon Sep 17 00:00:00 2001 From: Michael Tremer Date: Mon, 1 Feb 2021 18:27:40 +0000 Subject: [PATCH] client: Use a random port to connect to the server Signed-off-by: Michael Tremer --- src/client.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/src/client.c b/src/client.c index 82ae528..401a4f8 100644 --- a/src/client.c +++ b/src/client.c @@ -109,13 +109,16 @@ static int open_connection(struct fireperf_config* conf) { goto ERROR; } - DEBUG(conf, "Opening socket %d...\n", fd); + // Chose a random port + int port = conf->port + (random() % conf->sockets); + + DEBUG(conf, "Opening socket %d (port %d)...\n", fd, port); // Define the peer struct sockaddr_in6 peer = { .sin6_family = AF_INET6, .sin6_addr = conf->address, - .sin6_port = htons(conf->port), + .sin6_port = htons(port), }; // Enable keepalive -- 2.47.3