I’ve been looking for an answer to this question for a while now. I have written a small, lightweight server and it runs just fine really. No problems there; however, there’s some things I would like to do with the application while it’s actually running. For example: server stop to obviously halt the server.
Perhaps I should be looking at making a daemon for my server? The platform it runs on is Linux, and I have no intentions of porting to non-POSIX platforms, so Windows isn’t relevant here.
But yes, to summarize my question: how to make my application receive ‘arguments’ or ‘tasks’ from outside (such as the command line, or a different application)
Cheers in advance, as I know StackOverflow is always ready with a solid, quick answer,
/Jesse
There is a variety of options. One popular solution is to use POSIX-style signals. Basically you install a signal handler and react to signals.
If that is too simplistic (because e.g. you need to accept parameters), you could also let your daemon open a socket where it listens for commands. You then write a small helper program to send commands to the socket. You can also do something similar using a named pipe.
Basically what you are looking for is called Inter-process communication (IPC). The Wikipedia page may point you in the right direction.