Re: Winsock2 SO_SNDBUF / UDP message send process

Tech-Archive recommends: Fix windows errors by optimizing your registry



There's no fixed buffer behind the socket as the model
suggests. There's buffer size. The actual buffer extends
and shrinks to hold as much data as necessary (it's not
even continuous piece of memory for that matter). BTW
you can easily abuse this elastic buffer by passing huge
sends (with TCP only, UDP has a maximum datagram
size) and eventually leading to out of buffers errors.
The socket won't accept any more data until its buffer
shrinks below the send buffer size (from data being
sent out).

--
=====================================
Alexander Nickolov
Microsoft MVP [VC], MCSD
email: agnickolov@xxxxxxxx
MVP VC FAQ: http://vcfaq.mvps.org
=====================================

<wforrester@xxxxxxxxx> wrote in message
news:1170406050.357638.26050@xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
What will happen if my send buffer doesn't have enough capacity to
hold 80 bytes,
and Winsock hasn't had time to send the first 50 bytes datagram?
Will it discard the second packet or return some error code to me?

On Feb 1, 10:12 am, "Arkady Frenkel" <arka...@xxxxxxxxxxxxxxxx> wrote:
Why that bother you? TCP stack will send packets and that problem of peer
side to extract datagram exactly as needed. As about internals, TCP stack
should send data immediately : UDP doesn't wait for ACK opposite to TCP
where even if you disable Nagle algorithm stack wait for ACK from peer.

Arkady

<wforres...@xxxxxxxxx> wrote in message

news:1170238259.634504.143510@xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx



I'm asking whether multipe calls to send() with a UDP socket can get
coalesced into an internal buffer
and than sent in a separate UDP datagram each?

Example:
I call send() twice, passing 50 bytes and 30 bytes buffers.
If at the time of the second call, Winsock2 hasn't yet sent out first
50 bytes,
will it append next 30 bytes to its internal buffer (to send 2
datagrams later) and exit the call
or it will block until first 50 bytes are actually sent?

On Jan 30, 11:50 pm, "Skywing [MVP]"
<skywing_NO_SP...@xxxxxxxxxxxxxxxxxxx> wrote:
If you're asking whether multiple calls to send() with a UDP socket
can
get
coalesced into a single UDP datagram on the wire, the answer is no.
UDP
provides message boundaries, unlike TCP.

--
Ken Johnson (Skywing)
Windows SDK MVPhttp://www.nynaeve.net<wforres...@xxxxxxxxx> wrote in
message

news:1170194811.950280.146300@xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx

- Show quoted text -- Hide quoted text -

- Show quoted text -




.



Relevant Pages

  • Re: blocking/nonblocking socket and select -> usefull?
    ... recvbuffer on TCP is a good indication, ... Just because you got one UDP datagram out of the ... So for TCP this means nonblocking read make no sense because: ...
    (comp.unix.programmer)
  • Re: Internal TCP/IP send buffer?
    ... > quickly therefore I need to minimize buffering on both the sender and the ... Then TCP is the wrong protocol for you. ... What is this buffer, and what can I do to work ... TCP to be made to behave like UDP. ...
    (microsoft.public.win32.programmer.networks)
  • Re: recvfrom buffer size problem
    ... There's nothing wrong with supplying a bigger buffer. ... of the size of the largest datagram you anticipate. ... Having some trouble allocating the ... char * cBuf = NULL; ...
    (microsoft.public.win32.programmer.networks)
  • Re: buffer overflow in /proc/sys/sunrpc/transports
    ... | tcp 1048576 ... | udp 32768 ... maybe just add checking for user buffer length? ...
    (Linux-Kernel)
  • Re: Reading from a message-oriented socket (UDP)
    ... To find max UDP buffer you can use getsockoptwith SO_MAX_MSG_SIZE (IIRC ... IMHO it will be interesting for you to read article about UDP in February ... So, when calling recvfrom() for UDP packets, if I want to be on the safe ... datagram. ...
    (microsoft.public.win32.programmer.networks)