Re: select.select and socket.setblocking



Francesco Bochicchio ha scritto:

No, in blocking mode it will wait to receive _some_ data (1 or
more bytes). The "requested" amount is strictly an upper
limit: recv won't return more than the requested number of
bytes, but it might return less.


Uhm. In my experience, with TCP protocol recv only returned less than the required bytes if the remote end disconnects. I always check the
returned value of recv and signal an error if the read bytes are less than the expected ones, but this error is never occurred (and its about 20 years that I use sockets in various languages and various flavor of unix and occasionally on windows. Maybe have always been lucky ? :-)


BTW, this is not a rethorical or ironic question... my applications mostly run on LANs or dedicated WANs so maybe they never experienced the
kind of network congestion that could cause recv to return less than the expected amount of bytes ...

but then, IIRC TCP guarantees that the packet is fully received by hand-shaking at transport level between sender and receiver. Ad once the packet is fully in the receiver buffer, why should recv choose to give
back to the application only a piece of it?

Ciao
-----
FB
.



Relevant Pages

  • Re: Socket differences between localhost and LAN (or Internet)
    ... Recv() is not reliable, ok, is the Sendreliable too? ... I see that the total amount of received bytes is not what I expected, ... The other bytes of the transmission are in transit. ... along the path from sender to receiver. ...
    (microsoft.public.vc.ide_general)
  • Re: Socket differences between localhost and LAN (or Internet)
    ... Recv() is not reliable, ok, is the Sendreliable too? ... I see that the total amount of received bytes is not what I expected, ... program proceeds on its way, why is Recvso stupid to return a value ... while (totalrecv < 1024) ...
    (microsoft.public.vc.ide_general)
  • non-blocking recv() problem when webserver disconnects
    ... If I'm correct shall recv() ... return the amount of bytes revived at particular moment, ... when EOF and –1 when error. ... the program there until the socket timeouts. ...
    (comp.os.linux.networking)
  • Re: Platform SDK: Windows Sockets
    ... MSDN: "The amount of data that can actually be read in a single call to the ... recvfrom function is limited to the data size written in the send ... How can I obtain the amount of whole data in the socket buffer? ...
    (microsoft.public.win32.programmer.networks)
  • Re: Synchronization with CAsyncSocket in CE 6.0
    ... number of bytes in the first packet, followed by packets of, say 1024 bytes. ... recv() operations, reassembling it into the format that you need. ... don't forget that recv can return zero, if the socket has ... So, CAsyncSocket while possibly a bad way to do things, does not appear to ...
    (microsoft.public.windowsce.embedded)