From: Michael Tremer Date: Mon, 1 Feb 2021 18:27:40 +0000 (+0000) Subject: client: Use a random port to connect to the server X-Git-Tag: 0.1.0~21 X-Git-Url: http://git.ipfire.org/gitweb/gitweb.cgi?a=commitdiff_plain;h=210dafcaf6bdb0428ee20967a90ff9f8cc3d5199;p=fireperf.git client: Use a random port to connect to the server Signed-off-by: Michael Tremer --- 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