From cf897932ca13b46b71de1d509ca7b262b718a464 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Bodo=20M=C3=B6ller?= Date: Fri, 2 Apr 1999 23:35:43 +0000 Subject: [PATCH] Avoid EADDRINUSE for s_server. Submitted by: Reviewed by: PR: --- apps/s_socket.c | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/apps/s_socket.c b/apps/s_socket.c index 6274acf53b..0030b57936 100644 --- a/apps/s_socket.c +++ b/apps/s_socket.c @@ -342,6 +342,12 @@ char *ip; s=socket(AF_INET,SOCK_STREAM,SOCKET_PROTOCOL); if (s == INVALID_SOCKET) goto err; +#if defined SOL_SOCKET && defined SO_REUSEADDR + { + int i = 1; + setsockopt(s, SOL_SOCKET, SO_REUSEADDR, &i, sizeof i); + } +#endif if (bind(s,(struct sockaddr *)&server,sizeof(server)) == -1) { #ifndef WINDOWS -- 2.25.1