I want to write a daemon that will receive commands.
What it the best approach? I am thinking of two variants:
1. daemon to be a tcp server that will include a tcp client. Then from command line I can run
./daemon --command acommand (this will not start another daemon but will run the tcp client that will connect to the already started daemon and will send the command).
2. daemon to be a tcp server and to have another program that will be the client (a separate binary). And then I will run from command line the client that will connect to the server and send commands.
There's not much difference between those two variants, apache for example uses apachectl as the client. Many well known services use distinct client/server apps. But there are other that have the client embeded into them.
Is it weird to run from command line a daemon as a client?
What it the best approach? I am thinking of two variants:
1. daemon to be a tcp server that will include a tcp client. Then from command line I can run
./daemon --command acommand (this will not start another daemon but will run the tcp client that will connect to the already started daemon and will send the command).
2. daemon to be a tcp server and to have another program that will be the client (a separate binary). And then I will run from command line the client that will connect to the server and send commands.
There's not much difference between those two variants, apache for example uses apachectl as the client. Many well known services use distinct client/server apps. But there are other that have the client embeded into them.
Is it weird to run from command line a daemon as a client?