You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Describe the bug
When the remote side of a TCP socket shuts the socket down for writing, all unread bytes on a passive socket which have been received by gen_tcp are immediately discarded and no longer accessible.
To Reproduce
The following escript demonstrates the issue:
Secondly, gen_tcp, probably in the name of usability, has a subtly different meaning of the Length argument compared to C socket recv(). It means a length that must be fulfilled; if less is received it is considered a failure and if the socket gets closed before Length bytes has been received, then none are returned. The function signature doesn't permit anything like {error, closed, PartialData}.
But if you use Length = 11 (length of "hello world"), or Length = 0 (return whatever available), in combination with {active,false} it also works:
Describe the bug
When the remote side of a TCP socket shuts the socket down for writing, all unread bytes on a passive socket which have been received by gen_tcp are immediately discarded and no longer accessible.
To Reproduce
The following escript demonstrates the issue:
This produces the error:
Expected behavior
gen_tcp should return the remaining bytes before returning
{error,closed}
Affected versions
25, 26, 27 known, likely all
Additional context
C++ program which shows the expected behavior
The text was updated successfully, but these errors were encountered: