3

I don't understand the main difference between WSASendTo, WSASendMsg, and TransmitPackets for sending in-memory buffers:

  • They all allow buffer gathering

  • All of them allow overlapped (asynchronous) operation

  • WSASendTo and TransmitPackets both allow stream sockets (WSASendMsg doesn't seem to)

Obviously there are some minor functionality difference (for example, only WSASendMsg can send control information), but I'm not talking about those, since there is no choice to be made there.
For the most part, they all seem the same, and I imagine one of them is used by the rest.

What I'm wondering is, if I'm just sending data from an in-memory buffer to a stream or datagram socket, how do I choose which one to use?

Is any of them faster/better? Or, do they differ in any aspects such as (but not limited to):

  • Packet efficiency?

  • How big the buffers can be?

  • How big their queue sizes are?

  • Blocking vs. error behavior when the queue is full?

  • Cache behavior? (note that I'm not talking about sending files, just memory buffers)

  • Or anything else?

user541686
  • 205,094
  • 128
  • 528
  • 886
  • 1
    `WSASendTo()` and `WSASendMsg()` both transmit data into the socket send buffer. What happens after that is entirely up to the transport layer and doesn't change. – user207421 Sep 05 '16 at 20:31
  • @EJP: Thanks. That begs the questions: (1) What's the difference between the first two, then? (2) In what sense is it not comparable? Can't I substitute them for each other? – user541686 Sep 05 '16 at 20:34
  • The difference between the first two is the API itself, as you have already noted. `TransmitPackets()` is unknown to me but it has some interaction with the OS elements you mentioned, all documented. – user207421 Sep 05 '16 at 20:34
  • @EJP: I'll phrase it another way. If I'm sending datagrams, and I'm not sending control information, are they different at all? – user541686 Sep 05 '16 at 20:38
  • Once you get past the API and start moving data they are exactly the same. I thought I had already said that. Oh wait, I did. – user207421 Sep 05 '16 at 20:42
  • @EJP: OK, well I didn't sure what "is up to the transport layer" meant. I thought it might include "the transport layer may decide to treat them differently, and we don't know". – user541686 Sep 05 '16 at 20:45

0 Answers0