]> git.netwichtig.de Git - user/henk/code/inspircd.git/blobdiff - include/socketengine.h
Add SocketEngine::WriteV()
[user/henk/code/inspircd.git] / include / socketengine.h
index 3a15e98c1475cfefd252596c85913754ef4d0812..f30289913b8b929008c08281e02c57cc12759e11 100644 (file)
 #include "socket.h"
 #include "base.h"
 
+#ifndef _WIN32
+#include <sys/uio.h>
+#endif
+
+#ifndef IOV_MAX
+#define IOV_MAX 1024
+#endif
+
 /** Types of event an EventHandler may receive.
  * EVENT_READ is a readable file descriptor,
  * and EVENT_WRITE is a writeable file descriptor.
@@ -306,6 +314,12 @@ class CoreExport SocketEngine
        }
 
 public:
+#ifndef _WIN32
+       typedef iovec IOVector;
+#else
+       typedef WindowsIOVec IOVector;
+#endif
+
        /** Constructor.
         * The constructor transparently initializes
         * the socket engine which the ircd is using.
@@ -346,8 +360,10 @@ public:
         */
        static void ChangeEventMask(EventHandler* eh, int event_mask);
 
-       /** Returns the highest file descriptor you may store in the socket engine
-        * @return The maximum fd value
+       /** Returns the number of file descriptors reported by the system this program may use
+        * when it was started.
+        * @return If positive, the number of file descriptors that the system reported that we
+        * may use. Otherwise (<= 0) this number could not be determined.
         */
        static int GetMaxFds() { return MAX_DESCRIPTORS; }
 
@@ -432,6 +448,27 @@ public:
         */
        static int Send(EventHandler* fd, const void *buf, size_t len, int flags);
 
+       /** Abstraction for vector write function writev().
+        * This function should emulate its namesake system call exactly.
+        * @param fd EventHandler to send data with
+        * @param iov Array of IOVectors containing the buffers to send and their lengths in the platform's
+        * native format.
+        * @param count Number of elements in iov.
+        * @return This method should return exactly the same values as the system call it emulates.
+        */
+       static int WriteV(EventHandler* fd, const IOVector* iov, int count);
+
+#ifdef _WIN32
+       /** Abstraction for vector write function writev() that accepts a POSIX format iovec.
+        * This function should emulate its namesake system call exactly.
+        * @param fd EventHandler to send data with
+        * @param iov Array of iovecs containing the buffers to send and their lengths in POSIX format.
+        * @param count Number of elements in iov.
+        * @return This method should return exactly the same values as the system call it emulates.
+        */
+       static int WriteV(EventHandler* fd, const iovec* iov, int count);
+#endif
+
        /** Abstraction for BSD sockets recv(2).
         * This function should emulate its namesake system call exactly.
         * @param fd This version of the call takes an EventHandler instead of a bare file descriptor.