Packets sent from Linux TCP socket

Hello,

Our software is using a TCP socket (AF_INET, SOCK_STREAM) to communicate with an Ethernet device. When we send a message, the message object writes itself in full onto the socket's stream buffer before the software invokes send() from socket.h.

I'm still researching, but have 2 questions:

1) After send() is invoked, is the information in the socket buffer broken into multiple packets? If so, what determines how the buffer contents are "broken up"?
2) Is there a way to guarantee that the buffer contents are sent across in a single packet?

Thanks
Dan

Stream sockets are streams. You don't know or care about things like what data goes in what packet. Neither does the receiving program. What actually happens, depends. The packets between the source and destination can be split up, recombined, merged, dropped, retransmitted, folded, spindled, and mutilated in a variety of interesting ways, not just before/during transmission, but after transmission, by hosts along the way. TCP does a lot of work for you, to make it simple for you to use.

If you don't want streams, don't use streams. You get what you want with UDP -- that sends individual packets, as you want, when you want them, without the benefit of arriving in the correct order or allowing the client to read them in whatever chunks they want. Of course they have a maximum size; that's what packet means.