#include <UPIPE_Connector.h>
Public Types | |
| typedef ACE_UPIPE_Addr | PEER_ADDR |
| typedef ACE_UPIPE_Stream | PEER_STREAM |
Public Member Functions | |
| ACE_UPIPE_Connector (void) | |
| Default constructor. | |
| ACE_UPIPE_Connector (ACE_UPIPE_Stream &new_stream, const ACE_UPIPE_Addr &addr, ACE_Time_Value *timeout=0, const ACE_Addr &local_sap=ACE_Addr::sap_any, int reuse_addr=0, int flags=O_RDWR, int perms=0) | |
| int | connect (ACE_UPIPE_Stream &new_stream, const ACE_UPIPE_Addr &addr, ACE_Time_Value *timeout=0, const ACE_Addr &local_sap=ACE_Addr::sap_any, int reuse_addr=0, int flags=O_RDWR, int perms=0) |
| int | reset_new_handle (ACE_HANDLE handle) |
| Resets any event associations on this handle. | |
| void | dump (void) const |
| Dump the state of an object. | |
Public Attributes | |
| ACE_ALLOC_HOOK_DECLARE | |
| Declare the dynamic allocation hooks. | |
Definition at line 34 of file UPIPE_Connector.h.
|
|
Definition at line 95 of file UPIPE_Connector.h. |
|
|
Definition at line 96 of file UPIPE_Connector.h. |
|
|
Default constructor.
Definition at line 29 of file UPIPE_Connector.cpp. References ACE_TRACE.
00030 {
00031 ACE_TRACE ("ACE_UPIPE_Connector::ACE_UPIPE_Connector");
00032 }
|
|
||||||||||||||||||||||||||||||||
|
Actively connect and produce a new_stream if things go well. The addr is the address that we are trying to connect with. The timeout is the amount of time to wait to connect. If it's 0 then we block indefinitely. If *timeout == {0, 0} then the connection is done using non-blocking mode. In this case, if the connection can't be made immediately the value of -1 is returned with <errno == EWOULDBLOCK>. If *timeout > {0, 0} then this is the maximum amount of time to wait before timing out. If the time expires before the connection is made <errno == ETIME>. The local_sap is the value of local address to bind to. If it's the default value of ACE_Addr::sap_any then the user is letting the OS do the binding. If reuse_addr == 1 then the local_addr is reused, even if it hasn't been cleanedup yet. The flags and perms arguments are passed down to the open() method. Definition at line 9 of file UPIPE_Connector.inl. References ACE_ERROR, ACE_LIB_TEXT, ACE_TRACE, connect(), ETIME, EWOULDBLOCK, and LM_ERROR.
00016 {
00017 ACE_TRACE ("ACE_UPIPE_Connector::ACE_UPIPE_Connector");
00018 if (this->connect (new_stream, addr, timeout, local_sap,
00019 reuse_addr, flags, perms) == -1
00020 && timeout != 0 && !(errno == EWOULDBLOCK || errno == ETIME))
00021 ACE_ERROR ((LM_ERROR,
00022 ACE_LIB_TEXT ("address %s, %p\n"),
00023 addr.get_path_name (),
00024 ACE_LIB_TEXT ("ACE_UPIPE_Connector")));
00025 }
|
|
||||||||||||||||||||||||||||||||
|
Actively connect and produce a new_stream if things go well. The addr is the address that we are trying to connect with. The timeout is the amount of time to wait to connect. If it's 0 then we block indefinitely. If *timeout == {0, 0} then the connection is done using non-blocking mode. In this case, if the connection can't be made immediately the value of -1 is returned with <errno == EWOULDBLOCK>. If *timeout > {0, 0} then this is the maximum amount of time to wait before timing out. If the time expires before the connection is made <errno == ETIME>. The local_sap is the value of local address to bind to. If it's the default value of ACE_Addr::sap_any then the user is letting the OS do the binding. If reuse_addr == 1 then the local_addr is reused, even if it hasn't been cleanedup yet. The flags and perms arguments are passed down to the open() method. Definition at line 35 of file UPIPE_Connector.cpp. References ACE_ASSERT, ACE_ERROR, ACE_GUARD_RETURN, ACE_LIB_TEXT, ACE_TRACE, ACE_UPIPE_Stream::get_handle(), ACE::handle_timed_open(), ACE_OS::isastream(), LM_ERROR, ACE_UPIPE_Stream::recv(), ACE_UPIPE_Stream::reference_count_, ACE_UPIPE_Stream::remote_addr_, ACE_IPC_SAP::set_handle(), ssize_t, and ACE_OS::write(). Referenced by ACE_UPIPE_Connector().
00042 {
00043 ACE_TRACE ("ACE_UPIPE_Connector::connect");
00044 ACE_ASSERT (new_stream.get_handle () == ACE_INVALID_HANDLE);
00045
00046 ACE_HANDLE handle = ACE::handle_timed_open (timeout,
00047 addr.get_path_name (),
00048 flags, perms);
00049
00050 if (handle == ACE_INVALID_HANDLE)
00051 return -1;
00052 #if !defined (ACE_WIN32)
00053 else if (ACE_OS::isastream (handle) != 1)
00054 return -1;
00055 #endif
00056 else // We're connected!
00057 {
00058 ACE_MT (ACE_GUARD_RETURN (ACE_Thread_Mutex, ace_mon, new_stream.lock_, -1));
00059
00060 ACE_UPIPE_Stream *ustream = &new_stream;
00061
00062 new_stream.set_handle (handle);
00063 new_stream.remote_addr_ = addr; // class copy.
00064 new_stream.reference_count_++;
00065
00066 // Now send the address of our ACE_UPIPE_Stream over this pipe
00067 // to our corresponding ACE_UPIPE_Acceptor, so he may link the
00068 // two streams.
00069 ssize_t result = ACE_OS::write (handle,
00070 (const char *) &ustream,
00071 sizeof ustream);
00072 if (result == -1)
00073 ACE_ERROR ((LM_ERROR,
00074 ACE_LIB_TEXT ("ACE_UPIPE_Connector %p\n"),
00075 ACE_LIB_TEXT ("write to pipe failed")));
00076
00077 // Wait for confirmation of stream linking.
00078 ACE_Message_Block *mb_p = 0;
00079
00080 // Our part is done, wait for server to confirm connection.
00081 result = new_stream.recv (mb_p, 0);
00082
00083 // Do *not* coalesce the following two checks for result == -1.
00084 // They perform different checks and cannot be merged.
00085 if (result == -1)
00086 ACE_ERROR ((LM_ERROR,
00087 ACE_LIB_TEXT ("ACE_UPIPE_Connector %p\n"),
00088 ACE_LIB_TEXT ("no confirmation from server")));
00089 else
00090 // Close down the new_stream at this point in order to
00091 // conserve handles. Note that we don't need the SPIPE
00092 // connection anymore since we're linked via the Message_Queue
00093 // now.
00094 new_stream.ACE_SPIPE::close ();
00095 return static_cast<int> (result);
00096 }
00097 }
|
|
|
Dump the state of an object.
Definition at line 22 of file UPIPE_Connector.cpp. References ACE_TRACE.
00023 {
00024 #if defined (ACE_HAS_DUMP)
00025 ACE_TRACE ("ACE_UPIPE_Connector::dump");
00026 #endif /* ACE_HAS_DUMP */
00027 }
|
|
|
Resets any event associations on this handle.
Definition at line 28 of file UPIPE_Connector.inl.
00029 {
00030 // Nothing to do here since the handle is not a socket
00031 return 0;
00032 }
|
|
|
Declare the dynamic allocation hooks.
Definition at line 102 of file UPIPE_Connector.h. |
1.3.6