I have this code with asyncSocket on linux:
while true:
var msgSize = ""
while msgSize.len == 0:
try:
msgSize = await asocket.recv(4, flags={SocketFlag.Peek})
await sleepAsync(200)
except ...
try:
resp = await asocket.recv(4 + msg2Int(msgSize))
(proces message...)
Run
This works as expected, until I get a larger message (16kB, confirmed with
wireshark that I actually receive it). What happens is that it gets stuck on
recv the first 4 bytes in peek mode, it stays at 0, even though I have not
gotten the data out of the socket buffer. If I remove the Peek flag, and adjust
the code (remove +4 from the second recv size), I get the expected data.
<https://man7.org/linux/man-pages/man2/recv.2.html> :
MSG_PEEK
This flag causes the receive operation to return data from the beginning of
the receive queue without removing that data from the queue. Thus, a subsequent
receive call will return the same data.
Any idea what could be going on ?