Cast uint8* in InterruptibleRecv to char* for recv

Fixes a Windows-specific compile bug introduced in #4212.
Closes #4214.
This commit is contained in:
Jack Grigg 2019-11-11 09:47:38 +00:00
parent 98b70f1264
commit 8f170cf033
No known key found for this signature in database
GPG Key ID: 9E8255172BBF9898
1 changed files with 7 additions and 1 deletions

View File

@ -254,7 +254,13 @@ bool static InterruptibleRecv(uint8_t* data, size_t len, int timeout, SOCKET& hS
// to break off in case of an interruption.
const int64_t maxWait = 1000;
while (len > 0 && curTime < endTime) {
ssize_t ret = recv(hSocket, data, len, 0); // Optimistically try the recv first
// Optimistically try the recv first.
//
// POSIX recv() does not require a cast, as it takes a void *buf:
// ssize_t recv(int sockfd, void *buf, size_t len, int flags);
// However Windows explicitly requires a char *buf:
// int recv(SOCKET s, char *buf, int len, int flags);
ssize_t ret = recv(hSocket, reinterpret_cast<char*>(data), len, 0);
if (ret > 0) {
len -= ret;
data += ret;