Changes to attempt to silence bcc64x
[ACE_TAO.git] / ACE / ace / ATM_Connector.cpp
blobb02a4435b4d24d27d8dc4f9483e29b41e9917507
1 // ATM_Connector.cpp
2 #include "ace/ATM_Connector.h"
3 #if defined (ACE_HAS_ATM)
5 #include "ace/Handle_Set.h"
7 #if !defined (__ACE_INLINE__)
8 #include "ace/ATM_Connector.inl"
9 #endif /* __ACE_INLINE__ */
11 // Open versioned namespace, if enabled by the user.
12 ACE_BEGIN_VERSIONED_NAMESPACE_DECL
14 ACE_ALLOC_HOOK_DEFINE(ACE_ATM_Connector)
16 ACE_ATM_Connector::ACE_ATM_Connector ()
18 ACE_TRACE ("ACE_ATM_Connector::ACE_ATM_Connector");
21 // Actively connect and produce a new ACE_ATM_Stream if things go well...
22 // Connect the <new_stream> to the <remote_sap>, waiting up to
23 // <timeout> amount of time if necessary.
24 int
25 ACE_ATM_Connector::connect (ACE_ATM_Stream &new_stream,
26 const ACE_ATM_Addr &remote_sap,
27 ACE_ATM_Params params,
28 ACE_ATM_QoS options,
29 ACE_Time_Value *timeout,
30 const ACE_ATM_Addr &local_sap,
31 int reuse_addr,
32 int flags,
33 int perms)
35 ACE_TRACE ("ACE_ATM_Connector::connect");
36 #if defined (ACE_HAS_FORE_ATM_XTI)
37 return connector_.connect(new_stream.get_stream(),
38 remote_sap,
39 timeout,
40 local_sap,
41 reuse_addr,
42 flags,
43 perms,
44 params.get_device(),
45 params.get_info(),
46 params.get_rw_flag(),
47 params.get_user_data(),
48 &options.get_qos());
49 #elif defined (ACE_HAS_FORE_ATM_WS2)
50 ACELIB_DEBUG(LM_DEBUG,
51 ACE_TEXT ("ATM_Connector(connect): set QoS parameters\n" ));
53 ACE_HANDLE s = new_stream.get_handle();
54 struct sockaddr_atm *saddr = ( struct sockaddr_atm *)remote_sap.get_addr();
55 ACE_QoS cqos = options.get_qos();
57 ACE_QoS_Params qos_params = ACE_QoS_Params(0,
59 &cqos,
61 0);
63 ACELIB_DEBUG(LM_DEBUG,
64 ACE_TEXT ("ATM_Connector(connect): connecting...\n"));
66 int result = ACE_OS::connect( s,
67 ( struct sockaddr *)saddr,
68 sizeof( struct sockaddr_atm ),
69 qos_params);
71 if ( result != 0 )
72 ACE_OS::printf( "ATM_Connector(connect): connection failed, %d\n",
73 ::WSAGetLastError());
75 return result;
76 #elif defined (ACE_HAS_LINUX_ATM)
77 ACE_UNUSED_ARG (params);
78 ACE_UNUSED_ARG (timeout);
79 ACE_UNUSED_ARG (reuse_addr);
80 ACE_UNUSED_ARG (perms);
81 ACE_UNUSED_ARG (flags);
83 ACE_HANDLE handle = new_stream.get_handle();
84 ATM_QoS qos =options.get_qos();
85 ATM_Addr *local_addr=(ATM_Addr*)local_sap.get_addr(),
86 *remote_addr=(ATM_Addr*)remote_sap.get_addr();
88 if (ACE_OS::setsockopt(handle,
89 SOL_ATM,
90 SO_ATMSAP,
91 reinterpret_cast<char*> (&(local_addr->atmsap)),
92 sizeof(local_addr->atmsap)) < 0) {
93 ACE_OS::printf( "ATM_Connector(connect): unable to set atmsap %d\nContinuing...",
94 errno);
96 if (ACE_OS::setsockopt(handle,
97 SOL_ATM,
98 SO_ATMQOS,
99 reinterpret_cast<char*> (&qos),
100 sizeof(qos)) < 0) {
101 ACELIB_DEBUG((LM_DEBUG,ACE_TEXT ("ATM_Connector(connect): unable to set qos %d\n"),
102 errno));
103 return -1;
106 int result = ACE_OS::connect(handle,
107 (struct sockaddr *)&(remote_addr->sockaddratmsvc),
108 sizeof( remote_addr->sockaddratmsvc));
110 if ( result != 0 )
111 ACELIB_DEBUG(LM_DEBUG,
112 ACE_TEXT ("ATM_Connector(connect): connection failed, %d\n"),
113 errno);
115 return result;
116 #else
117 ACE_UNUSED_ARG (new_stream);
118 ACE_UNUSED_ARG (remote_sap);
119 ACE_UNUSED_ARG (params);
120 ACE_UNUSED_ARG (options);
121 ACE_UNUSED_ARG (timeout);
122 ACE_UNUSED_ARG (local_sap);
123 ACE_UNUSED_ARG (reuse_addr);
124 ACE_UNUSED_ARG (flags);
125 ACE_UNUSED_ARG (perms);
126 return 0;
127 #endif /* ACE_HAS_FORE_ATM_XTI || ACE_HAS_FORE_ATM_WS2 || ACE_HAS_LINUX_ATM */
130 // Close versioned namespace, if enabled by the user.
131 ACE_END_VERSIONED_NAMESPACE_DECL
133 #endif /* ACE_HAS_ATM */