Unix socket – creating the server
Unix sockets are similar to TCP/IP sockets, but they are only local and are represented by a socket file on the filesystem. But the overall functions that are used with Unix sockets are more or less the same as for TCP/IP sockets. The complete name for Unix sockets is Unix domain sockets.
Unix sockets are a common way for programs to communicate locally on a machine.
Knowing how to use Unix sockets will make it easier to write programs that need to communicate between them.
Getting ready
In this recipe, you'll only need the GCC compiler, the Make tool, and the generic Makefile.
How to do it…
In this recipe, we'll write a program that will act as a server. It will receive messages from a client and respond with "Message received" every time a message is received. It will also clean up after itself when either the server or the client exits. Let's get started:
- Write the following code in...