diff options
Diffstat (limited to 'lib')
-rw-r--r-- | lib/Socket.cc | 8 |
1 files changed, 6 insertions, 2 deletions
diff --git a/lib/Socket.cc b/lib/Socket.cc index f66fc5f..21acf3f 100644 --- a/lib/Socket.cc +++ b/lib/Socket.cc @@ -17,7 +17,7 @@ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ -/* $Id: Socket.cc,v 1.26 2008-07-23 16:08:10 pixel Exp $ */ +/* $Id: Socket.cc,v 1.27 2008-09-22 20:55:02 pixel Exp $ */ #ifdef _WIN32 #include <winsock2.h> @@ -121,7 +121,6 @@ bool Socket::SetLocal(const String & vhost, int port) { struct in_addr localhostaddr; struct sockaddr_in localsocketaddr; - memset((void *)&localhostaddr, 0, sizeof(localhostaddr)); if (vhost.strlen() != 0) { @@ -139,6 +138,11 @@ bool Socket::SetLocal(const String & vhost, int port) { localsocketaddr.sin_addr = localhostaddr; localsocketaddr.sin_port = htons(port); +#ifndef _WIN32 + int enable = 1; + setsockopt(GetHandle(), SOL_SOCKET, SO_REUSEADDR, &enable, sizeof(enable)); +#endif + if (bind(GetHandle(), (struct sockaddr *) &localsocketaddr, sizeof(localsocketaddr)) < 0) { return false; } else { |