For that, text is often beneficial - it is easier to debug when you can see what's going wrong. You might well linearize (serialize) the data - possibly fancily with something like ASN.1 or probably more simply with a format that can be reread easily. However, if there's any chance that the systems might be different, then you need to establish how the data will be transferred formally. If ((nbytes = write(sockfd, &some, sizeof(some)) != sizeof(some)) If you are sure, for all time (which most of us cannot be), then you can take some shortcuts - but you must be aware that they are shortcuts. It depends on whether you can be sure that your systems on either end of the connection are homogeneous or not. The last parameter, protocol specifies a particular protocol to be used with the socket. There are more socket types but outside the scope of this post. Assume the struct to be the following: Stream sockets use the underlying Transmission Control Protocol (TCP), whereas the datagram sockets use the User Datagram Protocol (UDP). Socket Programming socket: a data structure containing connection, I have a small client server application in which i wish to send an entire structure over a TCP socket in C not C++. At least, not without a proven performance issue. I also strongly recommend not designing a network protocol around the specifics of your hardware.
Once you have a specification, it's much easier to answer questions about how one end or the other should be designed. (And if both ends follow the specification and it still doesn't work, the specification is at fault.) If something goes wrong, which end is at fault? With a specification, the end that didn't follow the specification is at fault. Without a specification, it's easy to ask questions that are simply impossible to answer. It should specify how the ends of messages are established, whether there are any timeouts and who imposes them, and so on. But it does have to specify who transmits what when and it must specify all messages at the byte level. It doesn't have to be a multiple-page document filled with technical jargon.
Before you send any data over a TCP connection, work out a protocol specification.