Skip to content

Commit

Permalink
better partial message handling
Browse files Browse the repository at this point in the history
  • Loading branch information
lsalzman committed Jul 24, 2023
1 parent ea4607a commit 2a85cd6
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 2 deletions.
3 changes: 3 additions & 0 deletions protocol.c
Original file line number Diff line number Diff line change
Expand Up @@ -1243,6 +1243,9 @@ enet_protocol_receive_incoming_commands (ENetHost * host, ENetEvent * event)
& buffer,
1);

if (receivedLength == -2)
continue;

if (receivedLength < 0)
return -1;

Expand Down
2 changes: 1 addition & 1 deletion unix.c
Original file line number Diff line number Diff line change
Expand Up @@ -509,7 +509,7 @@ enet_socket_receive (ENetSocket socket,

#ifdef HAS_MSGHDR_FLAGS
if (msgHdr.msg_flags & MSG_TRUNC)
return -1;
return -2;
#endif

if (address != NULL)
Expand Down
4 changes: 3 additions & 1 deletion win32.c
Original file line number Diff line number Diff line change
Expand Up @@ -382,13 +382,15 @@ enet_socket_receive (ENetSocket socket,
case WSAEWOULDBLOCK:
case WSAECONNRESET:
return 0;
case WSAEMSGSIZE:
return -2;
}

return -1;
}

if (flags & MSG_PARTIAL)
return -1;
return -2;

if (address != NULL)
{
Expand Down

0 comments on commit 2a85cd6

Please sign in to comment.