I am currently learning to program with unix domain sockets and I have a question about it.
What is the standard way to separate message?
E.g. A server writes two messages and the client needs can do two reads to get the message.
I guess I could “define” my own protocol by always appending a certain char sequence at the end of each message, but this does not seem right.
The null char seems to get thrown away when writing to a socket.
I would be really grateful for some clarification, especially if it comes within the next 2 hours :D.
I am currently learning to program with unix domain sockets and I have a
Share
First up “unix sockets” usually refers to “unix domain socket”, a special form of IPC.
That’s unlikely. You’re probably no writing right.
A simpler way would be to precede each “message” with a header containing the length. For example
An even simpler approach would be to use a protocol that has notions of messages, i.e. something like UDP or SCTP where a
sendequates to at most onerecv.