blob: bface44e341b8ecc9f730fcf75f9845267d0d3b1 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
|
// $Id$
#include "Server_i.h"
// A signal handler that will close the server object
extern "C" void handler (int)
{
Server::close();
}
int main (int, char **)
{
// The server object that abstracts away all of difficult parts.
Server server;
// Attempt to open the server. Like all good ACE-based
// objects, we'll get -1 on failure.
if( server.open() == -1 )
{
ACE_ERROR_RETURN ((LM_ERROR, "%p\n", "server.open()"), -1);
}
// Install a signal handler for ^C so that we can exit gracefully
ACE_Sig_Action sa ((ACE_SignalHandler) handler, SIGINT);
// Run the server's main loop until we're interrupted
if( server.run() == -1 )
{
ACE_ERROR_RETURN ((LM_ERROR, "%p\n", "server.run()"), -1);
}
return 0;
}
/* These explicit instantiations were taken from an earlier tutorial.
Your compiler may require others as well.
*/
#if defined (ACE_HAS_EXPLICIT_TEMPLATE_INSTANTIATION)
template class ACE_Acceptor <Handler, ACE_SOCK_ACCEPTOR>;
template class ACE_Svc_Handler<ACE_SOCK_STREAM, ACE_NULL_SYNCH>;
#elif defined (ACE_HAS_TEMPLATE_INSTANTIATION_PRAGMA)
#pragma instantiate ACE_Acceptor <Handler, ACE_SOCK_ACCEPTOR>
#pragma instantiate ACE_Svc_Handler<ACE_SOCK_STREAM, ACE_NULL_SYNCH>
#endif /* ACE_HAS_EXPLICIT_TEMPLATE_INSTANTIATION */
|