summaryrefslogtreecommitdiff
path: root/src/socketengine.cpp
diff options
context:
space:
mode:
authorbrain <brain@e03df62e-2008-0410-955e-edbf42e46eb7>2008-04-15 23:56:38 +0000
committerbrain <brain@e03df62e-2008-0410-955e-edbf42e46eb7>2008-04-15 23:56:38 +0000
commit73eb66f2b1c82f9e1d1a24093aa4a305c2cfe2e7 (patch)
treec5f33384af4e3396df64ebd6cbe5f3ae1df59d79 /src/socketengine.cpp
parent51b96abc0e5be16c3988d726afb25d0e7b5b7cae (diff)
Fix the problems GreenReaper found with the windows select engine, this has never worked properly in trunk! -- This needs tidying up, its on my todo either tonight if im awake enough, or tomorrow evening
git-svn-id: http://svn.inspircd.org/repository/trunk/inspircd@9514 e03df62e-2008-0410-955e-edbf42e46eb7
Diffstat (limited to 'src/socketengine.cpp')
-rw-r--r--src/socketengine.cpp33
1 files changed, 19 insertions, 14 deletions
diff --git a/src/socketengine.cpp b/src/socketengine.cpp
index d0c181be4..dd80b7f94 100644
--- a/src/socketengine.cpp
+++ b/src/socketengine.cpp
@@ -121,17 +121,6 @@ bool SocketEngine::BoundsCheckFd(EventHandler* eh)
return true;
}
-#ifdef WINDOWS
-
-int SocketEngine::Accept(EventHandler* fd, sockaddr *addr, socklen_t *addrlen) { return -1; }
-int SocketEngine::Close(int fd) { return -1; }
-int SocketEngine::Close(EventHandler* fd) { return -1; }
-int SocketEngine::Blocking(int fd) { return -1; }
-int SocketEngine::NonBlocking(int fd) { return -1; }
-int SocketEngine::GetSockName(EventHandler* fd, sockaddr *name, socklen_t* namelen) { return -1; }
-int SocketEngine::RecvFrom(EventHandler* fd, void *buf, size_t len, int flags, sockaddr *from, socklen_t *fromlen) { return -1; }
-
-#else
int SocketEngine::Accept(EventHandler* fd, sockaddr *addr, socklen_t *addrlen)
{
@@ -140,24 +129,42 @@ int SocketEngine::Accept(EventHandler* fd, sockaddr *addr, socklen_t *addrlen)
int SocketEngine::Close(EventHandler* fd)
{
+#ifdef WINDOWS
+ return closesocket(fd->GetFd());
+#else
return close(fd->GetFd());
+#endif
}
int SocketEngine::Close(int fd)
{
+#ifdef WINDOWS
+ return closesocket(fd);
+#else
return close(fd);
+#endif
}
int SocketEngine::Blocking(int fd)
{
+#ifdef WINDOWS
+ unsigned long opt = 0;
+ return ioctlsocket(fd, FIONBIO, &opt);
+#else
int flags = fcntl(fd, F_GETFL, 0);
return fcntl(fd, F_SETFL, flags ^ O_NONBLOCK);
+#endif
}
int SocketEngine::NonBlocking(int fd)
{
+#ifdef WINDOWS
+ unsigned long opt = 1;
+ return ioctlsocket(fd, FIONBIO, &opt);
+#else
int flags = fcntl(fd, F_GETFL, 0);
return fcntl(fd, F_SETFL, flags | O_NONBLOCK);
+#endif
}
int SocketEngine::GetSockName(EventHandler* fd, sockaddr *name, socklen_t* namelen)
@@ -167,11 +174,9 @@ int SocketEngine::GetSockName(EventHandler* fd, sockaddr *name, socklen_t* namel
int SocketEngine::RecvFrom(EventHandler* fd, void *buf, size_t len, int flags, sockaddr *from, socklen_t *fromlen)
{
- return recvfrom(fd->GetFd(), buf, len, flags, from, fromlen);
+ return recvfrom(fd->GetFd(), (char*)buf, len, flags, from, fromlen);
}
-#endif
-
int SocketEngine::Send(EventHandler* fd, const void *buf, size_t len, int flags)
{
return send(fd->GetFd(), (const char*)buf, len, flags);