1

When any two programs, no matter how simple or complicated, communicate by internet domain sockets (or Unix domain sockets), does it necessarily imply that there is an application-layer protocol for their communication?

Can such an application-layer protocol be either well known and defined (such as HTTP) or ad hoc (without being defined explicitly)?

For example, psql and postgresql server communicate by unix or internet domain sockets, and Virtual Machine Manager and KVM/QEMU communicate by unix or internet domain sockets. I was wondering if programs like them necessarily communicate using their own protocols.

This will help me to understand the concept of a protocol (an application-layer protocol in particular).

Thanks.

2
  • Sockets are similar to RS-232 ( old tech guy here, who lamented the loss of 25 pin serial ports ) in that there's a method to pass data, but how that data is used is up to the implementer. There are simple examples included in the manual page of a program by the name of socket ... not to be confused with the man page of "socket()" ... one example is a one line: socket -wslqvp "echo Socket! " 1938 ... for the server, and then connect via: socket -v localhost 1938 ... which outputs Socket! and exits. Commented Feb 25, 2019 at 15:05
  • Well, unlike internet socket, for unix domain socket, there's no other layers(no data packaging/unpackaging overhead for IPC). And UDS might be used to transfer some thing like crendential or file descriptor, other than pure byte stream, so when you say "application layer", that mostly fit with internet socket. Commented Feb 26, 2019 at 3:24

2 Answers 2

3

A protocol is just a set way of communication. Nothing else. How strict or how loose they are is another matter.

There's nothing stopping communication from being completely chaotic. You can use netcat to communicate two endpoints, and the data you send between is restricted only by what is to be achieved by the data exchange. It can be pure nonsense if you want, meaning there's no restriction whatsoever.

3

Yes. Two programs talking to each other must follow some sort of protocol for how that communication should happen. The protocol does not need to be a standard or a formal (as in published, or even written down) protocol, but they must somehow agree on by what means and in what order they should communicate, and what the data that they pass to each other mean.

An analogy is a person exiting a grocery shop by paying for their goods at a check-out counter. There is an agreement of protocol there, and it includes an informal agreement regarding things like what language to use and what currency the monetary transaction should be done in. The protocol also says in what order things need to happen for the person to be able to later exit the store (legally) with the newly bought groceries. This protocol also involves exchange of information necessary for the person to choose whether they are paying using cash or a debit card. Asking to pay with anything else, or asking to pay too early or too late during the check-out process will confuse the person behind the counter, as would speaking in an unknown (incompatible) language.

Sometimes, you break that protocol by wanting to pay by cash at a card-only check-out till. You will then have restart the procedure at a counter that accepts cash. This information was given to you in an early transaction message (a sign saying "debit cards only") that you ignored.

You can see some examples of the protocol messages being sent back and forth between server and client when connecting to an SSH server by ssh using -vvv. On the client side, you will see messages about identifying the remote server's SSH protocol version and sending our own client version. There will be messages about agreeing on what ciphers to use and what authentication methods are attempted etc. You may also see the corresponding server side messages if you start the SSH daemon in debug mode and connect to it with a client.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .