~ubuntu-branches/ubuntu/breezy/ace/breezy

« back to all changes in this revision

Viewing changes to performance-tests/SCTP/SOCK_SEQPACK_Association_Test.cpp

  • Committer: Bazaar Package Importer
  • Author(s): Adam Conrad, Benjamin Montgomery, Adam Conrad
  • Date: 2005-09-18 22:51:38 UTC
  • mfrom: (1.2.1 upstream) (2.1.1 sarge) (0.1.2 woody)
  • Revision ID: james.westby@ubuntu.com-20050918225138-seav22q6fyylb536
Tags: 5.4.7-3ubuntu1
[ Benjamin Montgomery ]
* Added a patch for amd64 and powerpc that disables the compiler
  option -fvisibility-inlines-hidden

[ Adam Conrad ]
* Added DPATCH_OPTION_CPP=1 to debian/patches/00options to make
  Benjamin's above changes work correctly with dpatch.

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
// SOCK_SEQPACK_Association_Test.cpp,v 1.2 2003/11/01 11:15:24 dhinton Exp
2
 
 
3
 
// ============================================================================
4
 
//
5
 
// = LIBRARY
6
 
//    tests
7
 
//
8
 
// = FILENAME
9
 
//    SOCK_SEQPACK_Association_Test.cpp
10
 
//
11
 
// = DESCRIPTION
12
 
//
13
 
//   Tests the methods get_local_addrs and get_remote_addrs of class
14
 
//   ACE_SOCK_SEQPACK_Association.
15
 
//
16
 
//   This is not an automated "one-button" test.  Rather, it prints
17
 
//   some output to a log file, so that an interested human can
18
 
//   inspect the output and get a vague notion of whether or not
19
 
//   the methods are working properly.
20
 
//
21
 
// = AUTHOR
22
 
//    Edward Mulholland (emulholl@atl.lmco.com)
23
 
//
24
 
// ============================================================================
25
 
 
26
 
#include "ace/SOCK_SEQPACK_Association.h"
27
 
#include "ace/SOCK_SEQPACK_Connector.h"
28
 
#include "ace/INET_Addr.h"
29
 
#include "ace/Log_Msg.h"
30
 
 
31
 
void dump_names(const ACE_SOCK_SEQPACK_Association& assoc);
32
 
 
33
 
int main (int argc, ACE_TCHAR *argv[])
34
 
{
35
 
  int status = 0;     // Innocent until proven guilty
36
 
 
37
 
  // object that manages the connection to the server
38
 
  ACE_SOCK_SEQPACK_Connector connector;
39
 
 
40
 
  // object that manages the data xfer between the client and server
41
 
  ACE_SOCK_SEQPACK_Association dataStream;
42
 
 
43
 
  // object that represents the server's IP address and port
44
 
  ACE_INET_Addr serverAddr;
45
 
 
46
 
  if (argc < 2) {
47
 
 
48
 
    ACE_ERROR ((LM_ERROR,
49
 
                ACE_TEXT ("Usage: SOCK_SEQPACK_Association_Test hostname:port\n")));
50
 
    status = 1;
51
 
 
52
 
  } else if (serverAddr.set(argv[1])) {
53
 
 
54
 
    ACE_ERROR ((LM_ERROR,
55
 
                ACE_TEXT ("%p\n"),
56
 
                ACE_TEXT ("ACE_INET_Addr::set")));
57
 
    status = 1;
58
 
 
59
 
  } else if (connector.connect (dataStream, serverAddr)) {
60
 
 
61
 
    ACE_ERROR ((LM_ERROR,
62
 
                ACE_TEXT ("%p\n"),
63
 
                ACE_TEXT ("ACE_SOCK_SEQPACK_Connector::connect")));
64
 
    status = 1;
65
 
 
66
 
  } else {
67
 
 
68
 
    ACE_DEBUG ((LM_DEBUG,
69
 
                ACE_TEXT ("Connected to server at %s\n"),
70
 
                argv[1]));
71
 
 
72
 
    dump_names(dataStream);
73
 
  }
74
 
 
75
 
  dataStream.close();
76
 
 
77
 
  return status;
78
 
}
79
 
 
80
 
void dump_names(const ACE_SOCK_SEQPACK_Association& assoc)
81
 
{
82
 
  // Pre-declare for-loop index
83
 
  size_t i = 0;
84
 
 
85
 
  size_t in_out_size = 100;
86
 
  ACE_INET_Addr in_out[100];
87
 
 
88
 
  // Output char buffer
89
 
  const size_t outbuf_size = 1024;
90
 
  ACE_TCHAR outbuf[outbuf_size];
91
 
 
92
 
  // Get local addresses of the association
93
 
  if (assoc.get_local_addrs(in_out, in_out_size)) {
94
 
 
95
 
    ACE_ERROR((LM_ERROR,
96
 
               "%p\n",
97
 
               "get_local_addrs"));
98
 
    return;
99
 
  }
100
 
 
101
 
  ACE_DEBUG((LM_DEBUG, "Called get_local_addrs\n"));
102
 
 
103
 
  // Print individual results of get_local_addrs
104
 
  for (i = 0; i < in_out_size; ++i) {
105
 
 
106
 
    if (in_out[i].addr_to_string(outbuf, outbuf_size)) {
107
 
 
108
 
      ACE_ERROR((LM_ERROR,
109
 
                 "%p\n",
110
 
                 "addr_to_string"));
111
 
      return;
112
 
    }
113
 
 
114
 
    ACE_DEBUG((LM_DEBUG,
115
 
               "get_local_addrs[%i] = %s\n",
116
 
               i,
117
 
               outbuf));
118
 
  }
119
 
 
120
 
  // Reset in_out_size
121
 
  in_out_size = 100;
122
 
 
123
 
  // Get remote addresses of the association
124
 
  if (assoc.get_remote_addrs(in_out, in_out_size)) {
125
 
 
126
 
    ACE_ERROR((LM_ERROR,
127
 
               "%p\n",
128
 
               "get_remote_addrs"));
129
 
    return;
130
 
  }
131
 
 
132
 
  ACE_DEBUG((LM_DEBUG, "Called get_remote_addrs\n"));
133
 
 
134
 
  // Print individual results of get_remote_addrs
135
 
  for (i = 0; i < in_out_size; ++i) {
136
 
 
137
 
    if (in_out[i].addr_to_string(outbuf, outbuf_size)) {
138
 
 
139
 
      ACE_ERROR((LM_ERROR,
140
 
                 "%p\n",
141
 
                 "addr_to_string"));
142
 
      return;
143
 
    }
144
 
 
145
 
    ACE_DEBUG((LM_DEBUG,
146
 
               "get_remote_addrs[%i] = %s\n",
147
 
               i,
148
 
               outbuf));
149
 
  }
150
 
}
151
 
 
152