#include <SOCK.h>
Inheritance diagram for ACE_SOCK:
Public Member Functions | |
int | set_option (int level, int option, void *optval, int optlen) const |
Wrapper around the setsockopt system call. | |
int | get_option (int level, int option, void *optval, int *optlen) const |
Wrapper around the getsockopt system call. | |
int | close (void) |
int | get_local_addr (ACE_Addr &) const |
int | get_remote_addr (ACE_Addr &) const |
void | dump (void) const |
Dump the state of an object. | |
int | open (int type, int protocol_family, int protocol, int reuse_addr) |
Wrapper around the BSD-style socket system call (no QoS). | |
int | open (int type, int protocol_family, int protocol, ACE_Protocol_Info *protocolinfo, ACE_SOCK_GROUP g, u_long flags, int reuse_addr) |
Wrapper around the QoS-enabled WSASocket function. | |
Public Attributes | |
ACE_ALLOC_HOOK_DECLARE | |
Declare the dynamic allocation hooks. | |
Protected Member Functions | |
ACE_SOCK (int type, int protocol_family, int protocol=0, int reuse_addr=0) | |
ACE_SOCK (int type, int protocol_family, int protocol, ACE_Protocol_Info *protocolinfo, ACE_SOCK_GROUP g, u_long flags, int reuse_addr) | |
ACE_SOCK (void) | |
~ACE_SOCK (void) | |
Protected destructor. |
This class provides functions that are common to all of the <ACE_SOCK_*> classes. ACE_SOCK provides the ability to get and set socket options, get the local and remote addresses, and open and close a socket handle.
Definition at line 41 of file SOCK.h.
ACE_SOCK::ACE_SOCK | ( | int | type, | |
int | protocol_family, | |||
int | protocol = 0 , |
|||
int | reuse_addr = 0 | |||
) | [protected] |
Constructor with arguments to call the BSD-style socket
system call (no QoS).
Definition at line 115 of file SOCK.cpp.
References ACE_ERROR, ACE_TEXT, and LM_ERROR.
00119 { 00120 // ACE_TRACE ("ACE_SOCK::ACE_SOCK"); 00121 if (this->open (type, 00122 protocol_family, 00123 protocol, 00124 reuse_addr) == -1) 00125 ACE_ERROR ((LM_ERROR, 00126 ACE_TEXT ("%p\n"), 00127 ACE_TEXT ("ACE_SOCK::ACE_SOCK"))); 00128 }
ACE_SOCK::ACE_SOCK | ( | int | type, | |
int | protocol_family, | |||
int | protocol, | |||
ACE_Protocol_Info * | protocolinfo, | |||
ACE_SOCK_GROUP | g, | |||
u_long | flags, | |||
int | reuse_addr | |||
) | [protected] |
Constructor with arguments to call the QoS-enabled WSASocket
function.
Definition at line 164 of file SOCK.cpp.
References ACE_ERROR, ACE_TEXT, and LM_ERROR.
00171 { 00172 // ACE_TRACE ("ACE_SOCK::ACE_SOCK"); 00173 if (this->open (type, 00174 protocol_family, 00175 protocol, 00176 protocolinfo, 00177 g, 00178 flags, 00179 reuse_addr) == -1) 00180 ACE_ERROR ((LM_ERROR, 00181 ACE_TEXT ("%p\n"), 00182 ACE_TEXT ("ACE_SOCK::ACE_SOCK"))); 00183 }
ACE_SOCK::ACE_SOCK | ( | void | ) | [protected] |
ACE_BEGIN_VERSIONED_NAMESPACE_DECL ACE_INLINE ACE_SOCK::~ACE_SOCK | ( | void | ) | [protected] |
int ACE_SOCK::close | ( | void | ) |
Close the socket. This method also sets the object's handle value to ACE_INVALID_HANDLE.
Reimplemented in ACE_SOCK_Acceptor, ACE_SOCK_Dgram_Bcast, ACE_SOCK_SEQPACK_Acceptor, ACE_SOCK_SEQPACK_Association, and ACE_SOCK_Stream.
Definition at line 71 of file SOCK.cpp.
References ACE_TRACE, ACE_OS::closesocket(), and ACE_IPC_SAP::set_handle().
Referenced by ACE_SOCK_Stream::close(), ACE_SOCK_SEQPACK_Association::close(), ACE_SOCK_SEQPACK_Acceptor::close(), ACE_SOCK_Dgram_Bcast::close(), ACE_SOCK_Acceptor::close(), ACE_SOCK_CODgram::open(), and ACE_SOCK_Dgram::shared_open().
00072 { 00073 ACE_TRACE ("ACE_SOCK::close"); 00074 int result = 0; 00075 00076 if (this->get_handle () != ACE_INVALID_HANDLE) 00077 { 00078 result = ACE_OS::closesocket (this->get_handle ()); 00079 this->set_handle (ACE_INVALID_HANDLE); 00080 } 00081 return result; 00082 }
ACE_BEGIN_VERSIONED_NAMESPACE_DECL void ACE_SOCK::dump | ( | void | ) | const |
Dump the state of an object.
Reimplemented from ACE_IPC_SAP.
Reimplemented in ACE_LSOCK_Acceptor, ACE_LSOCK_CODgram, ACE_LSOCK_Dgram, ACE_LSOCK_Stream, ACE_MEM_Acceptor, ACE_SOCK_Acceptor, ACE_SOCK_CODgram, ACE_SOCK_Dgram, ACE_SOCK_Dgram_Bcast, ACE_SOCK_Dgram_Mcast, ACE_SOCK_IO, ACE_SOCK_SEQPACK_Acceptor, ACE_SOCK_SEQPACK_Association, and ACE_SOCK_Stream.
Definition at line 17 of file SOCK.cpp.
References ACE_TRACE.
00018 { 00019 #if defined (ACE_HAS_DUMP) 00020 ACE_TRACE ("ACE_SOCK::dump"); 00021 #endif /* ACE_HAS_DUMP */ 00022 }
int ACE_SOCK::get_local_addr | ( | ACE_Addr & | ) | const |
Return the local endpoint address in the referenced <ACE_Addr>. Returns 0 if successful, else -1.
Reimplemented in ACE_LSOCK_Acceptor, and ACE_LSOCK_Stream.
Definition at line 51 of file SOCK.cpp.
References ACE_TRACE, ACE_Addr::get_addr(), ACE_Addr::get_size(), ACE_OS::getsockname(), ACE_Addr::set_size(), and ACE_Addr::set_type().
Referenced by ACE_MEM_Acceptor::get_local_addr(), ACE_LSOCK_Stream::get_local_addr(), and ACE_Pipe::open().
00052 { 00053 ACE_TRACE ("ACE_SOCK::get_local_addr"); 00054 00055 int len = sa.get_size (); 00056 sockaddr *addr = reinterpret_cast<sockaddr *> (sa.get_addr ()); 00057 00058 if (ACE_OS::getsockname (this->get_handle (), 00059 addr, 00060 &len) == -1) 00061 return -1; 00062 00063 sa.set_type (addr->sa_family); 00064 sa.set_size (len); 00065 return 0; 00066 }
ACE_INLINE int ACE_SOCK::get_option | ( | int | level, | |
int | option, | |||
void * | optval, | |||
int * | optlen | |||
) | const |
Wrapper around the getsockopt
system call.
Definition at line 29 of file SOCK.inl.
References ACE_TRACE, and ACE_OS::getsockopt().
00033 { 00034 ACE_TRACE ("ACE_SOCK::get_option"); 00035 return ACE_OS::getsockopt (this->get_handle (), level, 00036 option, (char *) optval, optlen); 00037 }
int ACE_SOCK::get_remote_addr | ( | ACE_Addr & | ) | const |
Return the address of the remotely connected peer (if there is one), in the referenced ACE_Addr. Returns 0 if successful, else -1.
Reimplemented in ACE_LSOCK_Stream, ACE_SOCK_Acceptor, ACE_SOCK_Dgram, ACE_SOCK_Dgram_Bcast, and ACE_SOCK_SEQPACK_Acceptor.
Definition at line 33 of file SOCK.cpp.
References ACE_TRACE, ACE_Addr::get_addr(), ACE_Addr::get_size(), ACE_OS::getpeername(), ACE_Addr::set_size(), and ACE_Addr::set_type().
00034 { 00035 ACE_TRACE ("ACE_SOCK::get_remote_addr"); 00036 00037 int len = sa.get_size (); 00038 sockaddr *addr = reinterpret_cast<sockaddr *> (sa.get_addr ()); 00039 00040 if (ACE_OS::getpeername (this->get_handle (), 00041 addr, 00042 &len) == -1) 00043 return -1; 00044 00045 sa.set_size (len); 00046 sa.set_type (addr->sa_family); 00047 return 0; 00048 }
int ACE_SOCK::open | ( | int | type, | |
int | protocol_family, | |||
int | protocol, | |||
ACE_Protocol_Info * | protocolinfo, | |||
ACE_SOCK_GROUP | g, | |||
u_long | flags, | |||
int | reuse_addr | |||
) |
Wrapper around the QoS-enabled WSASocket
function.
Definition at line 131 of file SOCK.cpp.
References ACE_TRACE, ACE_IPC_SAP::set_handle(), SO_REUSEADDR, ACE_OS::socket(), and SOL_SOCKET.
00138 { 00139 ACE_TRACE ("ACE_SOCK::open"); 00140 00141 this->set_handle (ACE_OS::socket (protocol_family, 00142 type, 00143 protocol, 00144 protocolinfo, 00145 g, 00146 flags)); 00147 int one = 1; 00148 00149 if (this->get_handle () == ACE_INVALID_HANDLE) 00150 return -1; 00151 else if (reuse_addr 00152 && this->set_option (SOL_SOCKET, 00153 SO_REUSEADDR, 00154 &one, 00155 sizeof one) == -1) 00156 { 00157 this->close (); 00158 return -1; 00159 } 00160 else 00161 return 0; 00162 }
int ACE_SOCK::open | ( | int | type, | |
int | protocol_family, | |||
int | protocol, | |||
int | reuse_addr | |||
) |
Wrapper around the BSD-style socket
system call (no QoS).
Definition at line 85 of file SOCK.cpp.
References ACE_TRACE, PF_UNIX, ACE_IPC_SAP::set_handle(), SO_REUSEADDR, ACE_OS::socket(), and SOL_SOCKET.
Referenced by ACE_SOCK_SEQPACK_Acceptor::open(), ACE_SOCK_Dgram_Mcast::open(), ACE_SOCK_Dgram::open(), ACE_SOCK_CODgram::open(), ACE_SOCK_Acceptor::open(), ACE_SOCK_SEQPACK_Connector::shared_open(), and ACE_SOCK_Connector::shared_open().
00089 { 00090 ACE_TRACE ("ACE_SOCK::open"); 00091 int one = 1; 00092 00093 this->set_handle (ACE_OS::socket (protocol_family, 00094 type, 00095 protocol)); 00096 00097 if (this->get_handle () == ACE_INVALID_HANDLE) 00098 return -1; 00099 else if (protocol_family != PF_UNIX 00100 && reuse_addr 00101 && this->set_option (SOL_SOCKET, 00102 SO_REUSEADDR, 00103 &one, 00104 sizeof one) == -1) 00105 { 00106 this->close (); 00107 return -1; 00108 } 00109 return 0; 00110 }
ACE_INLINE int ACE_SOCK::set_option | ( | int | level, | |
int | option, | |||
void * | optval, | |||
int | optlen | |||
) | const |
Wrapper around the setsockopt
system call.
Definition at line 16 of file SOCK.inl.
References ACE_TRACE, and ACE_OS::setsockopt().
Referenced by ACE_Pipe::open(), ACE_SOCK_Dgram_Mcast::set_option(), and ACE_SOCK_Dgram_Mcast::unsubscribe_i().
00020 { 00021 ACE_TRACE ("ACE_SOCK::set_option"); 00022 return ACE_OS::setsockopt (this->get_handle (), level, 00023 option, (char *) optval, optlen); 00024 }
Declare the dynamic allocation hooks.
Reimplemented from ACE_IPC_SAP.
Reimplemented in ACE_LSOCK_Acceptor, ACE_LSOCK_CODgram, ACE_LSOCK_Dgram, ACE_LSOCK_Stream, ACE_MEM_Acceptor, ACE_SOCK_Acceptor, ACE_SOCK_CODgram, ACE_SOCK_Dgram, ACE_SOCK_Dgram_Bcast, ACE_SOCK_Dgram_Mcast, ACE_SOCK_IO, ACE_SOCK_SEQPACK_Acceptor, ACE_SOCK_SEQPACK_Association, and ACE_SOCK_Stream.