P
Peter
Hi,
I have the following (simplified for posting) main program:
-----------------------------------------
int _tmain( int argc, _TCHAR* argv[] )
{
//Create socket listener
SOCKET s = SetupListener(PORT);
//Accept connections and create threads
AcceptConnections(s);
return 0;
}
---------------------------------------
This is the main program at server side, it's simple. What we want now is to
add a control handler function to it, so that when user running server
program hit ctrl-C, the server console won't show ^C at the end, but call a
controlhandler function so that it might exit with some meaningful message
such as "Stopping myservice ...".
You can see my program is not a service, I wonder if there is anyway to
attach a controlhandler function to it, if I have to call StartDispatcher
(like service programs do), how can I do it in THE program?
The program is implemented with VC++.
Thanks,
Peter
I have the following (simplified for posting) main program:
-----------------------------------------
int _tmain( int argc, _TCHAR* argv[] )
{
//Create socket listener
SOCKET s = SetupListener(PORT);
//Accept connections and create threads
AcceptConnections(s);
return 0;
}
---------------------------------------
This is the main program at server side, it's simple. What we want now is to
add a control handler function to it, so that when user running server
program hit ctrl-C, the server console won't show ^C at the end, but call a
controlhandler function so that it might exit with some meaningful message
such as "Stopping myservice ...".
You can see my program is not a service, I wonder if there is anyway to
attach a controlhandler function to it, if I have to call StartDispatcher
(like service programs do), how can I do it in THE program?
The program is implemented with VC++.
Thanks,
Peter