Skip to content

Commit

Permalink
Cast uint8* in InterruptibleRecv to char* for recv
Browse files Browse the repository at this point in the history
Fixes a Windows-specific compile bug introduced in #4212.
Closes #4214.
  • Loading branch information
str4d authored and cryptorex committed Sep 9, 2022
1 parent 3a96465 commit 977cdc0
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion src/netbase.cpp
Original file line number Diff line number Diff line change
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 977cdc0

Please sign in to comment.