]> git.netwichtig.de Git - user/henk/code/inspircd.git/blobdiff - include/socketengine_iocp.h
Pedantic safe
[user/henk/code/inspircd.git] / include / socketengine_iocp.h
index 5de7af03f25ee5fc807c1dcc6ffb1b07684d94e0..b024828f1170654f878138f20af332b6704dba93 100644 (file)
@@ -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.
  *
  * ---------------------------------------------------
  */
 #include "inspircd.h"
 #include "socketengine.h"
 
+/** Socket overlapped event types
+ */
 enum SocketIOEvent
 {
+       /** Read ready */
        SOCKET_IO_EVENT_READ_READY                      = 0,
+       /** Write ready */
        SOCKET_IO_EVENT_WRITE_READY                     = 1,
+       /** Accept ready */
        SOCKET_IO_EVENT_ACCEPT                          = 2,
+       /** Error occured */
        SOCKET_IO_EVENT_ERROR                           = 3,
+       /** Number of events */
        NUM_SOCKET_IO_EVENTS                            = 4,
 };
 
+/** Represents a windows overlapped IO event
+ */
 class Overlapped
 {
  public:
+       /** Overlap event */
        OVERLAPPED m_overlap;
+       /** Type of event */
        SocketIOEvent m_event;
 #ifdef WIN64
+       /** Parameters */
        unsigned __int64 m_params;
 #else
+       /** Parameters */
        unsigned long m_params;
 #endif
-
+       /** Create an overlapped event
+        */
        Overlapped(SocketIOEvent ev, int params) : m_event(ev), m_params(params)
        {
                memset(&m_overlap, 0, sizeof(OVERLAPPED));
        }
 };
 
+/** Specific to UDP sockets with overlapped IO
+ */
 struct udp_overlap
 {
        unsigned char udp_buffer[600];
@@ -57,12 +73,16 @@ struct udp_overlap
        unsigned long udp_sockaddr_len;
 };
 
+/** Specific to accepting sockets with overlapped IO
+ */
 struct accept_overlap
 {
        int socket;
        char buf[1024];
 };
 
+/** Implementation of SocketEngine that implements windows IO Completion Ports
+ */
 class IOCPEngine : public SocketEngine
 {
        /** Creates a "fake" file descriptor for use with an IOCP socket.
@@ -94,6 +114,11 @@ class IOCPEngine : public SocketEngine
        map<int, EventHandler*> m_binding;
 
 public:
+       /** Holds the preallocated buffer passed to WSARecvFrom
+        * function. Yes, I know, it's a dirty hack.
+        */
+       udp_overlap * udp_ov;
+
        /** Creates an IOCP Socket Engine
         * @param Instance The creator of this object
         */
@@ -186,15 +211,22 @@ public:
         */
        EventHandler* GetIntRef(int fd);
 
-       /** Holds the preallocated buffer passed to WSARecvFrom\r
-        * function. Yes, I know, it's a dirty hack.\r
-        */\r
-       udp_overlap * udp_ov;\r
-};
+       bool BoundsCheckFd(EventHandler* eh);
 
-//typedef void(*OpHandler)(EventHandler)
-/** Event Handler Array
- */
+       virtual int Accept(EventHandler* fd, sockaddr *addr, socklen_t *addrlen);
+
+       virtual int RecvFrom(EventHandler* fd, void *buf, size_t len, int flags, struct sockaddr *from, socklen_t *fromlen);
+
+       virtual int Blocking(int fd);
+
+       virtual int NonBlocking(int fd);
+
+       virtual int GetSockName(EventHandler* fd, sockaddr *name, socklen_t* namelen);
+
+       virtual int Close(int fd);
+
+       virtual int Close(EventHandler* fd);
+};
 
 /** Creates a SocketEngine
  */