Unix socket – creating the client
In this recipe, we'll see how we can use the socket to communicate between a server and a client. Knowing how to communicate over a socket is essential to using sockets.
Before doing this recipe, you should have finished the previous recipe; otherwise, you won't have a server to talk to.
You'll also need the GCC compiler, the Make tool, and the generic Makefile for this recipe.
How to do it…
In this recipe, we'll write a client for the server that we wrote in the previous recipe. Once they are connected, the client can send messages to the server, and the server will respond with Message received. Let's get started:
- Write the following code in a file and save it as
unix-client.c. Since this code...