Added additional error handling for the bind() and listen() system calls
when setting up the listening socket.
This commit is contained in:
parent
6c2d7ebaa4
commit
c86d22226f
@ -2,6 +2,8 @@
|
||||
|
||||
* src/sock.c (opensock): If the Listen directive is in use, then
|
||||
we should bind outgoing address to this address.
|
||||
(listen_sock): Added error handling for the bind() and listen()
|
||||
calls when setting up the listening socket.
|
||||
|
||||
2002-04-12 Robert James Kaes <rjkaes@flarenet.com>
|
||||
|
||||
|
14
src/sock.c
14
src/sock.c
@ -1,4 +1,4 @@
|
||||
/* $Id: sock.c,v 1.24 2002-04-13 05:20:19 rjkaes Exp $
|
||||
/* $Id: sock.c,v 1.25 2002-04-13 19:03:18 rjkaes Exp $
|
||||
*
|
||||
* Sockets are created and destroyed here. When a new connection comes in from
|
||||
* a client, we need to copy the socket and the create a second socket to the
|
||||
@ -206,9 +206,17 @@ listen_sock(uint16_t port, socklen_t * addrlen)
|
||||
addr.sin_addr.s_addr = inet_addr("0.0.0.0");
|
||||
}
|
||||
|
||||
bind(listenfd, (struct sockaddr *) &addr, sizeof(addr));
|
||||
if (bind(listenfd, (struct sockaddr *) &addr, sizeof(addr)) < 0) {
|
||||
log_message(LOG_ERR, "Unable to bind listening socket because of %s",
|
||||
strerror(errno));
|
||||
return -1;
|
||||
}
|
||||
|
||||
listen(listenfd, MAXLISTEN);
|
||||
if (listen(listenfd, MAXLISTEN) < 0) {
|
||||
log_message(LOG_ERR, "Unable to start listening socket because of %s",
|
||||
strerror(errno));
|
||||
return -1;
|
||||
}
|
||||
|
||||
*addrlen = sizeof(addr);
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user