summaryrefslogtreecommitdiff
path: root/src/sockets.cpp
diff options
context:
space:
mode:
authorAdam <Adam@anope.org>2011-11-08 17:29:16 -0500
committerAdam <Adam@anope.org>2011-11-08 17:29:16 -0500
commitb5ff856f47d8e54d12c568462a06351633c29610 (patch)
treea4e2f96c59ee49aa5e6cacdfd30db6155151ad36 /src/sockets.cpp
parent97b9055f92f21cd91af44a3d5dacce0024536cff (diff)
Windows
Diffstat (limited to 'src/sockets.cpp')
-rw-r--r--src/sockets.cpp22
1 files changed, 3 insertions, 19 deletions
diff --git a/src/sockets.cpp b/src/sockets.cpp
index fa79d32f2..5e65a521c 100644
--- a/src/sockets.cpp
+++ b/src/sockets.cpp
@@ -285,11 +285,7 @@ ClientSocket *SocketIO::Accept(ListenSocket *s)
socklen_t size = sizeof(conaddr);
int newsock = accept(s->GetFD(), &conaddr.sa, &size);
-#ifndef INVALID_SOCKET
- static const int INVALID_SOCKET = -1;
-#endif
-
- if (newsock >= 0 && newsock != INVALID_SOCKET)
+ if (newsock >= 0)
{
ClientSocket *ns = s->OnAccept(newsock, conaddr);
ns->SetFlag(SF_ACCEPTED);
@@ -406,7 +402,7 @@ Socket::Socket(int sock, bool ipv6, int type) : Flags<SocketFlag>(SocketFlagStri
Socket::~Socket()
{
SocketEngine::DelSocket(this);
- CloseSocket(this->Sock);
+ close(this->Sock);
this->IO->Destroy();
}
@@ -431,13 +427,8 @@ bool Socket::IsIPv6() const
*/
bool Socket::SetBlocking()
{
-#ifdef _WIN32
- unsigned long opt = 0;
- return !ioctlsocket(this->GetFD(), FIONBIO, &opt);
-#else
int flags = fcntl(this->GetFD(), F_GETFL, 0);
return !fcntl(this->GetFD(), F_SETFL, flags & ~O_NONBLOCK);
-#endif
}
/** Mark a socket as non-blocking
@@ -445,13 +436,8 @@ bool Socket::SetBlocking()
*/
bool Socket::SetNonBlocking()
{
-#ifdef _WIN32
- unsigned long opt = 1;
- return !ioctlsocket(this->GetFD(), FIONBIO, &opt);
-#else
int flags = fcntl(this->GetFD(), F_GETFL, 0);
return !fcntl(this->GetFD(), F_SETFL, flags | O_NONBLOCK);
-#endif
}
/** Bind the socket to an ip and port
@@ -503,10 +489,8 @@ ListenSocket::ListenSocket(const Anope::string &bindip, int port, bool ipv6) : S
{
this->SetNonBlocking();
-#ifndef _WIN32
- int op = 1;
+ const char op = 1;
setsockopt(this->GetFD(), SOL_SOCKET, SO_REUSEADDR, &op, sizeof(op));
-#endif
this->bindaddr.pton(IPv6 ? AF_INET6 : AF_INET, bindip, port);
this->IO->Bind(this, bindip, port);