3 //=============================================================================
5 * @file Transport_Acceptor.h
7 * Interface for the Acceptor component of the TAO pluggable protocol
10 * @author Fred Kuhns <fredk@cs.wustl.edu>
12 //=============================================================================
14 #ifndef TAO_ACCEPTOR_H
15 #define TAO_ACCEPTOR_H
17 #include /**/ "ace/pre.h"
19 #include /**/ "tao/TAO_Export.h"
21 #if !defined (ACE_LACKS_PRAGMA_ONCE)
23 #endif /* ACE_LACKS_PRAGMA_ONCE */
25 #include "ace/Acceptor.h"
26 #include "tao/Basic_Types.h"
28 // Forward declarations.
29 ACE_BEGIN_VERSIONED_NAMESPACE_DECL
32 ACE_END_VERSIONED_NAMESPACE_DECL
34 TAO_BEGIN_VERSIONED_NAMESPACE_DECL
51 // ****************************************************************
53 /// The TAO-specific OMG assigned value for the TAG_ORB_TYPE tagged
56 * This number was assigned by the OMG. Do *NOT* change. The ASCII
57 * representation is "TA\x00". If necessary, we can request more ORB
60 const CORBA::ULong TAO_ORB_TYPE
= 0x54414f00U
;
62 // ****************************************************************
67 * @brief Abstract Acceptor class used for pluggable transports.
69 * Base class for the Acceptor bridge class.
71 * @todo Need to rename the class as TAO_Transport_Acceptor.
73 class TAO_Export TAO_Acceptor
76 TAO_Acceptor (CORBA::ULong tag
);
79 virtual ~TAO_Acceptor ();
81 /// The tag, each concrete class will have a specific tag value.
82 CORBA::ULong
tag () const;
84 /// Set the amount of time to delay accepting new connections in the
85 /// event that we encounter an error that may be transient.
86 void set_error_retry_delay (time_t delay
);
88 /// Method to initialize acceptor for address.
89 virtual int open (TAO_ORB_Core
*orb_core
,
94 const char *options
= 0) = 0;
97 * Open an acceptor with the given protocol version on a default
100 virtual int open_default (TAO_ORB_Core
*,
101 ACE_Reactor
*reactor
,
104 const char *options
= 0) = 0;
106 /// Closes the acceptor
107 virtual int close () = 0;
110 * Create the corresponding profile for this endpoint.
111 * If share_profile is set to true, the pluggable protocol
112 * implementation should try to add the endpoint to a profile
113 * in the mprofile that is of the same type. Currently, this
114 * is used when RT CORBA is enabled.
116 virtual int create_profile (const TAO::ObjectKey
&object_key
,
117 TAO_MProfile
&mprofile
,
118 CORBA::Short priority
) = 0;
120 /// Return 1 if the @a endpoint has the same address as the acceptor.
121 virtual int is_collocated (const TAO_Endpoint
*endpoint
) = 0;
124 * Returns the number of endpoints this acceptor is listening on. This
125 * is used for determining how many profiles will be generated
128 virtual CORBA::ULong
endpoint_count () = 0;
131 * This method fetches the @a key from the @a profile. Protocols that
132 * are pluggable can send data that are specific in the
133 * @c profile_data field encapsulated as a octet stream. This method
134 * allows those protocols to get the object key from the
137 virtual int object_key (IOP::TaggedProfile
&profile
,
138 TAO::ObjectKey
&key
) = 0;
140 /// This method is not directly associated with the method of the same
141 /// name on the ACE_Acceptor template class. However, it is called by
142 /// the TAO_Strategy_Acceptor method of the same name.
143 int handle_accept_error (ACE_Event_Handler
* base_acceptor
);
145 /// Perform the handle_timeout functionality to put this acceptor back
146 /// into the reactor to try accepting again.
147 int handle_expiration (ACE_Event_Handler
* base_acceptor
);
150 /// IOP protocol tag.
151 CORBA::ULong
const tag_
;
153 time_t error_retry_delay_
;
156 /// This is a drop-in replacement class for the ACE_Strategy_Acceptor.
157 /// It provides all of the same functionality and the additional
158 /// functionality of handling accept() errors with some sort of
159 /// configured action. All of the actual code is in the TAO_Acceptor
160 /// to avoid multiply-instantiated code that would be, in effect,
163 /// It is not declared nested within TAO_Acceptor as I originally wanted
164 /// because it caused an internal compiler error for the Tornado 2.2.1
166 template <class SVC_HANDLER
, ACE_PEER_ACCEPTOR_1
>
167 class TAO_Strategy_Acceptor
:
168 public ACE_Strategy_Acceptor
<SVC_HANDLER
, ACE_PEER_ACCEPTOR_2
>
171 TAO_Strategy_Acceptor (TAO_Acceptor
* acceptor
)
172 : acceptor_ (acceptor
)
176 virtual int handle_accept_error ()
178 return this->acceptor_
->handle_accept_error (this);
181 virtual int handle_timeout (const ACE_Time_Value
&, const void*)
183 return this->acceptor_
->handle_expiration (this);
187 TAO_Acceptor
* acceptor_
;
190 TAO_END_VERSIONED_NAMESPACE_DECL
192 #if defined (__ACE_INLINE__)
193 # include "tao/Transport_Acceptor.inl"
194 #endif /* __ACE_INLINE__ */
196 #include /**/ "ace/post.h"
198 #endif /* TAO_ACCEPTOR_H */