summaryrefslogtreecommitdiff
path: root/include/socketengine.h
diff options
context:
space:
mode:
authorAttila Molnar <attilamolnar@hush.com>2015-03-04 20:18:37 +0100
committerAttila Molnar <attilamolnar@hush.com>2015-03-04 20:18:37 +0100
commite0e1becc2f9129203966e69b2919582c11ab86f7 (patch)
tree960bc91c89790914a84042f2684b4bd82d556981 /include/socketengine.h
parent30810318020c2c40ad9c04e4c95d445dbbe157c3 (diff)
Add SocketEngine::WriteV()
Diffstat (limited to 'include/socketengine.h')
-rw-r--r--include/socketengine.h35
1 files changed, 35 insertions, 0 deletions
diff --git a/include/socketengine.h b/include/socketengine.h
index 895457b89..f30289913 100644
--- a/include/socketengine.h
+++ b/include/socketengine.h
@@ -29,6 +29,14 @@
#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.
@@ -434,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.