Skip to content

Commit

Permalink
Auto merge of #4216 - str4d:4214-windows-fix, r=mdr0id
Browse files Browse the repository at this point in the history
Cast uint8* in InterruptibleRecv to char* for recv

Fixes a Windows-specific compile bug introduced in #4212.
Closes #4214.
  • Loading branch information
zkbot committed Nov 11, 2019
2 parents 019507a + 8f170cf commit f859ae0
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion src/netbase.cpp
Expand Up @@ -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;
Expand Down

0 comments on commit f859ae0

Please sign in to comment.