Re: partial receive in socket recv() issue for large response

Tech Tip: Click here to run a free scan for Windows Errors and optimize PC performance



um, tcp will buffer packets... so you should be able to recieve as much as
the current value of SO_RCVBUF (see setsockopt) in a single call to recv
with a stream socket. I think the default is 8kb but dont quote me as
authorative :P

"Arkady Frenkel" <arkadyf@xxxxxxxxxxxxxxxx> wrote in message
news:ObUYdLt4GHA.3452@xxxxxxxxxxxxxxxxxxxxxxx
As addition to Dave's message :
You will never receive such buffer at one read, because MTU of ethernet
is
1500 bytes - the max number NIC send to peer at once
Arkady

"Dave Lowther" <davel@xxxxxxxxx> wrote in message
news:u%23eEuYs4GHA.696@xxxxxxxxxxxxxxxxxxxxxxx
"NAGA" <NAGA@xxxxxxxxxxxxxxxxxxxxxxxxx> wrote

<snip>

While debugging application following steps are successful.
-iStatus is valid for a large return value (72007 bytes) in following
call
iStatus = recv(sock, &Response[BufIdx], BufLen-BufIdx, 0);

However if I run the above program either in debug/release mode, I get
iStatus value as '7' instead of 72007.
Note: int BufLen = 96000

Can someone please tell me why it is going wrong during run time?
Another
notable thing is, for any response whose size is small (say less than
2K)
response comes back fine from recv()

Maybe it's not going wrong, it could be that your expectation is wrong.

You should not expect to receive all of the data that's been sent in one
call to recv().

When debugging there is more time for the data to be sent and arrive in
your socket.

HTH

Dave.






.



Relevant Pages

  • Re: CSocket problem
    ... > I'm having a problem with a byte stream socket connection. ... the receive buffer sometimes gets full. ... a stream socket does not throw away bytes. ... caused by sender code that ignores the rules. ...
    (microsoft.public.vc.mfc)
  • Unix Stream socket -- "send()" for large amount of data
    ... will be adding data to a buffer and another ... will be sending it to a stream socket via "send" as fast ... Is it better for the consumer to do a single "send" ... So if there's not much advantage to sending smaller chunks, ...
    (comp.unix.programmer)
  • Re: Error in SEND(2) man page ?
    ... This tells me that if doing a sendon a tcp non-blocking socket whose send buffer is full, the call should return with -1 and errno=EAGAIN. ... But running a trivial test app, sendwill indicate that is sent some but not all of the data buffer when the socket's send buffer is full. ... socket, as a stream socket has no real concept of "messages". ...
    (Linux-Kernel)
  • Re: recv WSAENOBUFS error
    ... cross-posting, I did cross-post it initially, but I just started using ... it always asks for the "packet length" amount in the call to recv. ... You can set kernel-mode buffer with setsockopt but you'll quickly finish ...
    (microsoft.public.win32.programmer.kernel)
  • Re: recv WSAENOBUFS error
    ... it always asks for the "packet length" amount in the call to recv. ... You can set kernel-mode buffer with setsockopt but you'll quickly finish ... your non-page (kernel) memory if you'll start to do it. ...
    (microsoft.public.win32.programmer.kernel)