summaryrefslogtreecommitdiff
path: root/src/socketengine.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/socketengine.cpp')
-rw-r--r--src/socketengine.cpp12
1 files changed, 9 insertions, 3 deletions
diff --git a/src/socketengine.cpp b/src/socketengine.cpp
index 2dbc82b27..478400d1b 100644
--- a/src/socketengine.cpp
+++ b/src/socketengine.cpp
@@ -152,9 +152,15 @@ int SocketEngine::NonBlocking(int fd)
#endif
}
-int SocketEngine::GetSockName(EventHandler* fd, sockaddr *name, socklen_t* namelen)
-{
- return getsockname(fd->GetFd(), name, namelen);
+void SocketEngine::SetReuse(int fd)
+{
+ int on = 1;
+ struct linger linger = { 0, 0 };
+ setsockopt(fd, SOL_SOCKET, SO_REUSEADDR, (char*)&on, sizeof(on));
+ /* This is BSD compatible, setting l_onoff to 0 is *NOT* http://web.irc.org/mla/ircd-dev/msg02259.html */
+ linger.l_onoff = 1;
+ linger.l_linger = 1;
+ setsockopt(fd, SOL_SOCKET, SO_LINGER, (char*)&linger, sizeof(linger));
}
int SocketEngine::RecvFrom(EventHandler* fd, void *buf, size_t len, int flags, sockaddr *from, socklen_t *fromlen)