diff options
author | Attila Molnar <attilamolnar@hush.com> | 2015-03-06 18:04:13 +0100 |
---|---|---|
committer | Attila Molnar <attilamolnar@hush.com> | 2015-03-06 18:04:13 +0100 |
commit | 30b78bc2f4f7b74574abfbb3a3c2dc04686d2e7d (patch) | |
tree | 6350a96f7d9fbc487bf2604e5d90ab2a31384d4b /include | |
parent | 11b10ac8a4193e6804778a3284945ce0828be4c1 (diff) | |
parent | 56b7e9f8bf32824e0725005fcd0d2fa14a4ce088 (diff) |
Merge branch 'master+writev'
Diffstat (limited to 'include')
-rw-r--r-- | include/socketengine.h | 35 |
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. |