Introduction
Introduction Statistics Contact Development Disclaimer Help
To self: reuseaddr before bind. - geomyidae - A small C-based gopherd.
git clone git://bitreich.org/geomyidae/ git://enlrupgkhuxnvlhsf6lc3fziv5h2hhfri…
Log
Files
Refs
Tags
README
LICENSE
---
commit 94382cb7360ec1e712df59e883381cee1344dd9a
parent d81d0fda6b372f9bd057b5c17e50079509875d94
Author: Christoph Lohmann <[email protected]>
Date: Sun, 24 Apr 2011 15:14:25 +0200
To self: reuseaddr before bind.
Diffstat:
M main.c | 7 ++++++-
1 file changed, 6 insertions(+), 1 deletion(-)
---
diff --git a/main.c b/main.c
@@ -254,7 +254,7 @@ main(int argc, char *argv[])
struct addrinfo hints, *ai, *rp;
struct sockaddr_storage clt;
socklen_t cltlen;
- int sock, dofork;
+ int sock, dofork, on;
char *port, *base, clienth[NI_MAXHOST], clientp[NI_MAXSERV];
char *user, *group, *bindip, *ohost, *sport;
struct passwd *us;
@@ -355,11 +355,16 @@ main(int argc, char *argv[])
return 1;
}
+ on = 1;
for(rp = ai; rp != nil; rp = rp->ai_next) {
listfd = socket(rp->ai_family, rp->ai_socktype,
rp->ai_protocol);
if(listfd < 0)
continue;
+ if(setsockopt(listfd, SOL_SOCKET, SO_REUSEADDR, &on,
+ sizeof(on)) < 0) {
+ break;
+ }
if(bind(listfd, rp->ai_addr, rp->ai_addrlen) == 0)
break;
close(listfd);
You are viewing proxied material from bitreich.org. The copyright of proxied material belongs to its original authors. Any comments or complaints in relation to proxied material should be directed to the original authors of the content concerned. Please see the disclaimer for more details.