summaryrefslogtreecommitdiff
path: root/src/socketengine.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/socketengine.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/socketengine.cpp')
-rw-r--r--src/socketengine.cpp86
1 files changed, 85 insertions, 1 deletions
diff --git a/src/socketengine.cpp b/src/socketengine.cpp
index 28ba8c252..d8291073e 100644
--- a/src/socketengine.cpp
+++ b/src/socketengine.cpp
@@ -6,7 +6,7 @@
* See: http://www.inspircd.org/wiki/index.php/Credits
*
* This program is free but copyrighted software; see
- * the file COPYING for details.
+ * the file COPYING for details.
*
* ---------------------------------------------------
*/
@@ -100,3 +100,87 @@ bool SocketEngine::BoundsCheckFd(EventHandler* eh)
return true;
}
+
+int SocketEngine::Accept(EventHandler* fd, sockaddr *addr, socklen_t *addrlen)
+{
+ return accept(fd->GetFd(), addr, addrlen);
+}
+
+int SocketEngine::Close(EventHandler* fd)
+{
+ return close(fd->GetFd());
+}
+
+int SocketEngine::Send(EventHandler* fd, const void *buf, size_t len, int flags)
+{
+ return send(fd->GetFd(), buf, len, flags);
+}
+
+int SocketEngine::Recv(EventHandler* fd, void *buf, size_t len, int flags)
+{
+ return recv(fd->GetFd(), buf, len, flags);
+}
+
+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);
+}
+
+int SocketEngine::SendTo(EventHandler* fd, const void *buf, size_t len, int flags, const sockaddr *to, socklen_t tolen)
+{
+ return sendto(fd->GetFd(), buf, len, flags, to, tolen);
+}
+
+int SocketEngine::Connect(EventHandler* fd, const sockaddr *serv_addr, socklen_t addrlen)
+{
+ return connect(fd->GetFd(), serv_addr, addrlen);
+}
+
+int SocketEngine::Blocking(int fd)
+{
+ int flags = fcntl(fd, F_GETFL, 0);
+ return fcntl(fd, F_SETFL, flags ^ O_NONBLOCK);
+}
+
+int SocketEngine::NonBlocking(int fd)
+{
+ int flags = fcntl(fd, F_GETFL, 0);
+ return fcntl(fd, F_SETFL, flags | O_NONBLOCK);
+}
+
+int SocketEngine::Shutdown(EventHandler* fd, int how)
+{
+ return shutdown(fd->GetFd(), how);
+}
+
+
+int SocketEngine::Bind(int fd, const sockaddr *my_addr, socklen_t addrlen)
+{
+ return bind(fd, my_addr, addrlen);
+}
+
+int SocketEngine::GetSockName(EventHandler* fd, sockaddr *name, socklen_t* namelen)
+{
+ return getsockname(fd->GetFd(), name, namelen);
+}
+
+int SocketEngine::Listen(int sockfd, int backlog)
+{
+ return listen(sockfd, backlog);
+}
+
+
+int SocketEngine::Shutdown(int fd, int how)
+{
+ return shutdown(fd, how);
+}
+
+int SocketEngine::Close(int fd)
+{
+ return close(fd);
+}
+
+void SocketEngine::RecoverFromFork()
+{
+}
+