summaryrefslogtreecommitdiff
path: root/src/inspsocket.cpp
diff options
context:
space:
mode:
authorbrain <brain@e03df62e-2008-0410-955e-edbf42e46eb7>2007-08-23 22:06:04 +0000
committerbrain <brain@e03df62e-2008-0410-955e-edbf42e46eb7>2007-08-23 22:06:04 +0000
commitd0d36795e807cf72295c6e73813e0c2daa0a71e7 (patch)
tree09ae4d94ed7b6f3038d2579037fd2c7ee93a6657 /src/inspsocket.cpp
parent61816ef0dd848225e9ec1c21c3c7a3bc03a34da9 (diff)
Craquity craq De-craq!
This is probably broken on windows, do not attempt to use there yet unless you like broken stuff. Cant say for sure as i havent even tried to build yet and most likely wont tonight. --- Abstract most of the berkely socket API out into SocketEngine derived classes. SocketEngine base class implements standard berkely sockets that 'real mens systems' like linux and freebsd have. For socketengine_iocp we implement the windows specific nonesense like the special things needed for udp and accept (ick). All this to eliminate a bunch of ifdefs. git-svn-id: http://svn.inspircd.org/repository/trunk/inspircd@7810 e03df62e-2008-0410-955e-edbf42e46eb7
Diffstat (limited to 'src/inspsocket.cpp')
-rw-r--r--src/inspsocket.cpp35
1 files changed, 14 insertions, 21 deletions
diff --git a/src/inspsocket.cpp b/src/inspsocket.cpp
index 2cfa6fd67..e2a2ab8ee 100644
--- a/src/inspsocket.cpp
+++ b/src/inspsocket.cpp
@@ -217,7 +217,7 @@ bool InspSocket::BindAddr(const std::string &ip)
}
}
- if (bind(this->fd, s, size) < 0)
+ if (Instance->SE->Bind(this->fd, s, size) < 0)
{
this->state = I_ERROR;
this->OnError(I_ERR_BIND);
@@ -302,14 +302,13 @@ bool InspSocket::DoConnect()
((sockaddr_in*)addr)->sin_port = htons(this->port);
}
}
-#ifndef WIN32
- int flags = fcntl(this->fd, F_GETFL, 0);
- fcntl(this->fd, F_SETFL, flags | O_NONBLOCK);
-#else
- unsigned long flags = 0;
- ioctlsocket(this->fd, FIONBIO, &flags);
+
+#ifdef WIN32
+ /* UGH for the LOVE OF ZOMBIE JESUS SOMEONE FIX THIS!!!!!!!!!!! */
+ Instance->SE->Blocking(this->fd);
#endif
- if (connect(this->fd, (sockaddr*)addr, size) == -1)
+
+ if (Instance->SE->Connect(this, (sockaddr*)addr, size) == -1)
{
if (errno != EINPROGRESS)
{
@@ -323,9 +322,8 @@ bool InspSocket::DoConnect()
this->Instance->Timers->AddTimer(this->Timeout);
}
#ifdef WIN32
- /* Set nonblocking mode after the connect() call */
- flags = 0;
- ioctlsocket(this->fd, FIONBIO, &flags);
+ /* CRAQ SMOKING STUFF TO BE FIXED */
+ Instance->SE->NonBlocking(this->fd);
#endif
this->state = I_CONNECTING;
if (this->fd > -1)
@@ -363,8 +361,8 @@ void InspSocket::Close()
Instance->Log(DEFAULT,"%s threw an exception: %s", modexcept.GetSource(), modexcept.GetReason());
}
}
- shutdown(this->fd,2);
- if (close(this->fd) != -1)
+ Instance->SE->Shutdown(this, 2);
+ if (Instance->SE->Close(this) != -1)
this->OnClose();
if (Instance->SocketCull.find(this) == Instance->SocketCull.end())
@@ -476,11 +474,8 @@ bool InspSocket::FlushWriteBuffer()
while (outbuffer.size() && (errno != EAGAIN))
{
/* Send a line */
-#ifndef WIN32
- int result = write(this->fd,outbuffer[0].c_str(),outbuffer[0].length());
-#else
- int result = send(this->fd,outbuffer[0].c_str(),outbuffer[0].length(), 0);
-#endif
+ int result = Instance->SE->Send(this, outbuffer[0].c_str(), outbuffer[0].length(), 0);
+
if (result > 0)
{
if ((unsigned int)result >= outbuffer[0].length())
@@ -604,9 +599,7 @@ bool InspSocket::Poll()
if ((!*this->host) || strchr(this->host, ':'))
length = sizeof(sockaddr_in6);
#endif
- void* m_acceptEvent = NULL;
- GetExt("windows_acceptevent", m_acceptEvent);
- incoming = _accept (this->fd, client, &length);
+ incoming = Instance->SE->Accept(this, client, &length);
#ifdef IPV6
if ((!*this->host) || strchr(this->host, ':'))
{