1 #include "ace/TLI_Acceptor.h"
2 #include "ace/ATM_Addr.h"
3 #include "ace/Log_Msg.h"
6 #if defined (ACE_HAS_FORE_ATM_XTI)
10 ACE_TMAIN (int argc
, ACE_TCHAR
*argv
[])
12 ACE_Time_Value
timeout (ACE_DEFAULT_TIMEOUT
);
14 unsigned char selector
= ACE_ATM_Addr::DEFAULT_SELECTOR
;
15 int selector_specified
= 0;
17 while ((opt
= ACE_OS::getopt (argc
, argv
, "s:?h")) != EOF
)
22 selector
= ACE_OS::atoi (optarg
);
23 selector_specified
= 1;
27 ACE_ERROR_RETURN ((LM_ERROR
,
28 "Usage: %s [-s selector]\n", argv
[0]),
33 // Create a server address.
35 if (selector_specified
)
36 addr
.set_selector(selector
);
38 // Create a server, reuse the addr.
39 ACE_TLI_Acceptor peer_acceptor
;
41 // Not sure why but reuse_addr set to true/1 causes problems for
42 // FORE/XTI/ATM - this is now handled in ACE_TLI_Acceptor::open()
43 if (peer_acceptor
.open (addr
,
48 ACE_XTI_ATM_DEVICE
) == -1)
49 ACE_ERROR_RETURN ((LM_ERROR
,
54 ACE_TLI_Stream new_stream
;
57 "starting server at address %s\n",
58 addr
.addr_to_string ()));
61 // Performs the iterative server activities
67 // Create a new ACE_TLI_Stream endpoint (note automatic restart
68 // if errno == EINTR).
69 if (peer_acceptor
.accept (new_stream
,
80 "client %s connected\n",
81 addr
.addr_to_string ()));
83 // Read data from client (terminate on error).
86 (r_bytes
= new_stream
.recv (buf
, sizeof buf
, 0)) > 0; )
87 if (ACE_OS::write (ACE_STDOUT
,
94 // Close new endpoint (listening endpoint stays open).
95 if (new_stream
.close () == -1)
104 int ACE_TMAIN (int, ACE_TCHAR
*[])
106 ACE_ERROR_RETURN ((LM_ERROR
,
107 "your platform isn't configured to support XTI/ATM\n"),
110 #endif /* ACE_HAS_TLI */