diff options
author | Attila Molnar <attilamolnar@hush.com> | 2015-03-04 20:05:00 +0100 |
---|---|---|
committer | Attila Molnar <attilamolnar@hush.com> | 2015-03-04 20:05:00 +0100 |
commit | 30810318020c2c40ad9c04e4c95d445dbbe157c3 (patch) | |
tree | 5fd00bbb518f08e9cbf7f25c84b0afdf183ee42f /win/inspircd_win32wrapper.h | |
parent | 19eb420281670348532fdd58f5fe757d5413faf7 (diff) |
Add writev() wrapper for Windows
Diffstat (limited to 'win/inspircd_win32wrapper.h')
-rw-r--r-- | win/inspircd_win32wrapper.h | 17 |
1 files changed, 17 insertions, 0 deletions
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<LPWSABUF>(const_cast<WindowsIOVec*>(iov)), count, &sent, 0, NULL, NULL); + if (ret == 0) + return sent; + return -1; +} |