I have a server that listens to stdin (user) and other clients.
Assume that the server is connected to many clients (using selectall file descriptors to manage it), and the user enters EXIT into the terminal. This means that the server must shut itself down.
What is the right way to shut down a server gracefully? Should the server go through all the file descriptors and close(fd)all or just close listenerfd? Alternatively, should I not close anything and just end the server process and exit?
I use only one thread in my program.
Thank.
source
share