introduce setsockopt_reuseaddr(int fd), setsockopt_broadcast(int fd),

use them where appropriate. 200 bytes saved
This commit is contained in:
Denis Vlasenko
2006-11-22 23:22:06 +00:00
parent b40bdb383a
commit 48237b0c88
16 changed files with 40 additions and 42 deletions

View File

@@ -802,7 +802,6 @@ static int openServer(void)
{
struct sockaddr_in lsocket;
int fd;
int on = 1;
/* create the socket right now */
/* inet_addr() returns a value that is already in network order */
@@ -814,9 +813,13 @@ static int openServer(void)
/* tell the OS it's OK to reuse a previous address even though */
/* it may still be in a close down state. Allows bind to succeed. */
#ifdef SO_REUSEPORT
setsockopt(fd, SOL_SOCKET, SO_REUSEPORT, (void *)&on, sizeof(on));
{
static const int on = 1;
setsockopt(fd, SOL_SOCKET, SO_REUSEPORT,
(void *)&on, sizeof(on));
}
#else
setsockopt(fd, SOL_SOCKET, SO_REUSEADDR, (void *)&on, sizeof(on));
setsockopt_reuseaddr(fd);
#endif
xbind(fd, (struct sockaddr *)&lsocket, sizeof(lsocket));
xlisten(fd, 9);