daemon to keep me connected to a server

Hi

I have a C++ program "binary" from now on called "A" which lets me
communicate some commands to a server over the Internet.
I have written my own C++ code "B" which uses A's interface, B decides
which A function to use and what its parameters should be based
on information retrieved from the server. the connection with the
server is established using

int main(int argc, char* argv[]){
char* username=argv[1];
char* password=argv[1];
object.login(username, password);
// etrieve info
// call function with suitable parameters
// stay connected all the time
// unless $ service myProg stop
...
}

could someone please point to a link on how can I use a daemon to fire
up on boot and stay connected all the time unless a service stop call
is issued on the command line?

my understanding is:
create an on_file.init
create an off_file.fini
set the user permission on them
create control_serv_file in /etc/init.d
link to suitable runlevel file S111 -> /etc/init.d/control_serv_file
start|stop|restart the service as pleased.

I don't what script to place in the files, specially the
on_file.init and off_file.fini files

thanks

No votes yet
Syndicate content