From 30810318020c2c40ad9c04e4c95d445dbbe157c3 Mon Sep 17 00:00:00 2001 From: Attila Molnar Date: Wed, 4 Mar 2015 20:05:00 +0100 Subject: [PATCH 1/1] Add writev() wrapper for Windows --- win/inspircd_win32wrapper.h | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/win/inspircd_win32wrapper.h b/win/inspircd_win32wrapper.h index a19bdf857..361724a2f 100644 --- a/win/inspircd_win32wrapper.h +++ b/win/inspircd_win32wrapper.h @@ -218,3 +218,20 @@ private: // Same value as EXIT_STATUS_FORK (EXIT_STATUS_FORK is unused on Windows) #define EXIT_STATUS_SERVICE 4 + +// Windows WSABUF with POSIX field names +struct WindowsIOVec +{ + // POSIX iovec has iov_base then iov_len, WSABUF in Windows has the fields in reverse order + u_long iov_len; // Number of bytes to transfer + char FAR* iov_base; // Starting address +}; + +inline ssize_t writev(int fd, const WindowsIOVec* iov, int count) +{ + DWORD sent; + int ret = WSASend(fd, reinterpret_cast(const_cast(iov)), count, &sent, 0, NULL, NULL); + if (ret == 0) + return sent; + return -1; +} -- 2.39.2