2 //=============================================================================
4 * @file SOCK_SEQPACK_Association_Test.cpp
6 * Tests the methods get_local_addrs and get_remote_addrs of class
7 * ACE_SOCK_SEQPACK_Association.
9 * This is not an automated "one-button" test. Rather, it prints
10 * some output to a log file, so that an interested human can
11 * inspect the output and get a vague notion of whether or not
12 * the methods are working properly.
14 * @author Edward Mulholland (emulholl@atl.lmco.com)
16 //=============================================================================
19 #include "ace/SOCK_SEQPACK_Association.h"
20 #include "ace/SOCK_SEQPACK_Connector.h"
21 #include "ace/INET_Addr.h"
22 #include "ace/Log_Msg.h"
24 void dump_names(const ACE_SOCK_SEQPACK_Association
& assoc
);
26 int ACE_TMAIN (int argc
, ACE_TCHAR
*argv
[])
28 int status
= 0; // Innocent until proven guilty
30 // object that manages the connection to the server
31 ACE_SOCK_SEQPACK_Connector connector
;
33 // object that manages the data xfer between the client and server
34 ACE_SOCK_SEQPACK_Association dataStream
;
36 // object that represents the server's IP address and port
37 ACE_INET_Addr serverAddr
;
41 ACE_TEXT ("Usage: SOCK_SEQPACK_Association_Test hostname:port\n")));
43 } else if (serverAddr
.set(argv
[1])) {
46 ACE_TEXT ("ACE_INET_Addr::set")));
48 } else if (connector
.connect (dataStream
, serverAddr
)) {
51 ACE_TEXT ("ACE_SOCK_SEQPACK_Connector::connect")));
55 ACE_TEXT ("Connected to server at %s\n"),
58 dump_names(dataStream
);
66 void dump_names(const ACE_SOCK_SEQPACK_Association
& assoc
)
68 // Pre-declare for-loop index
71 size_t in_out_size
= 100;
72 ACE_INET_Addr in_out
[100];
75 const size_t outbuf_size
= 1024;
76 ACE_TCHAR outbuf
[outbuf_size
];
78 // Get local addresses of the association
79 if (assoc
.get_local_addrs(in_out
, in_out_size
)) {
86 ACE_DEBUG((LM_DEBUG
, "Called get_local_addrs\n"));
88 // Print individual results of get_local_addrs
89 for (i
= 0; i
< in_out_size
; ++i
) {
90 if (in_out
[i
].addr_to_string(outbuf
, outbuf_size
)) {
98 "get_local_addrs[%i] = %s\n",
106 // Get remote addresses of the association
107 if (assoc
.get_remote_addrs(in_out
, in_out_size
)) {
110 "get_remote_addrs"));
114 ACE_DEBUG((LM_DEBUG
, "Called get_remote_addrs\n"));
116 // Print individual results of get_remote_addrs
117 for (i
= 0; i
< in_out_size
; ++i
) {
118 if (in_out
[i
].addr_to_string(outbuf
, outbuf_size
)) {
126 "get_remote_addrs[%i] = %s\n",