Building a TCP/IP Linux server and daemonizing it
In the previous recipes, we have seen how to create a TCP/IP server, manage the Linux signals, and how to create a Linux daemon. Through this newly acquired knowledge, in this new recipe we will be able to build a TCP/IP server that includes all the necessary considerations to be daemonized.
Getting ready
We will start from the project created in the first recipe, take that project and clone it in your filesystem; it will be the starting point.
In the code of this project, we should add the signal management and the parts necessary to be compatible with systemd
, so that it can be daemonized.
Let's start!
How to do it...
Perform the following steps:
- Open the project just cloned.
- Rename it in
tcpipserver_daemon
; you can do it by right-clicking on the project (in the project manager ) and then choosingRename.
- Add
Posix.Signal
in theuses
section. - We have to introduce the signal handling:
SIGINT
andSIGTERM
are the two signals that we're going to manage...