#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 system call. | |
| int | get_option (int level, int option, void *optval, int *optlen) const |
| Wrapper around the 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 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 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. 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.
|
||||||||||||||||||||
|
Constructor with arguments to call the BSD-style system call (no QoS). Definition at line 115 of file SOCK.cpp. References ACE_ERROR, ACE_LIB_TEXT, LM_ERROR, and open().
|
|
||||||||||||||||||||||||||||||||
|
Constructor with arguments to call the QoS-enabled function. Definition at line 164 of file SOCK.cpp. References ACE_ERROR, ACE_LIB_TEXT, ACE_SOCK_GROUP, LM_ERROR, and open().
|
|
|
Default constructor is protected to prevent instances of this class from being defined. Definition at line 24 of file SOCK.cpp.
00025 {
00026 // ACE_TRACE ("ACE_SOCK::ACE_SOCK");
00027 }
|
|
|
Protected destructor. Not a virtual destructor. Protected destructor to prevent operator delete() from being called through a base class ACE_SOCK pointer/reference. Definition at line 10 of file SOCK.inl.
00011 {
00012 // ACE_TRACE ("ACE_SOCK::~ACE_SOCK");
00013 }
|
|
|
Close the socket. This method also sets the object's handle value to ACE_INVALID_HANDLE.
Reimplemented in ACE_MEM_Stream, 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(), ACE_IPC_SAP::get_handle(), 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_MEM_Stream::close(), ACE_SOCK_CODgram::open(), open(), ACE_SOCK_Dgram::shared_open(), and ACE_ICMP_Socket::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 }
|
|
|
Dump the state of an object.
Reimplemented from ACE_IPC_SAP. Reimplemented in ACE_ICMP_Socket, ACE_LSOCK_Acceptor, ACE_LSOCK_CODgram, ACE_LSOCK_Dgram, ACE_LSOCK_Stream, ACE_MEM_Acceptor, ACE_MEM_IO, ACE_MEM_Stream, ACE_Ping_Socket, 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 }
|
|
|
Return the local endpoint address in the referenced . 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::accept(), ACE_MEM_Connector::connect(), ACE_MEM_Acceptor::get_local_addr(), ACE_LSOCK_Stream::get_local_addr(), ACE_Service_Manager::info(), ACE_Pipe::open(), ACE_SOCK_Dgram_Mcast::open_i(), and ACE_Asynch_Acceptor< HANDLER >::parse_address().
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 }
|
|
||||||||||||||||||||
|
Wrapper around the 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 }
|
|
|
Return the address of the remotely connected peer (if there is one), in the referenced . 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(). Referenced by ACE_Service_Manager::handle_input(), and ACE_Asynch_Acceptor< HANDLER >::parse_address().
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 }
|
|
||||||||||||||||||||||||||||||||
|
Wrapper around the QoS-enabled function.
Definition at line 131 of file SOCK.cpp. References ACE_SOCK_GROUP, ACE_TRACE, close(), ACE_IPC_SAP::get_handle(), ACE_IPC_SAP::set_handle(), and set_option().
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 }
|
|
||||||||||||||||||||
|
Wrapper around the BSD-style system call (no QoS).
Definition at line 85 of file SOCK.cpp. References ACE_TRACE, close(), ACE_IPC_SAP::get_handle(), ACE_IPC_SAP::set_handle(), and set_option(). Referenced by ACE_SOCK(), ACE_SOCK_SEQPACK_Acceptor::open(), ACE_SOCK_Dgram_Mcast::open(), ACE_SOCK_Dgram::open(), ACE_SOCK_CODgram::open(), ACE_SOCK_Acceptor::open(), ACE_ICMP_Socket::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 }
|
|
||||||||||||||||||||
|
Wrapper around the system call.
Definition at line 16 of file SOCK.inl. References ACE_TRACE, and ACE_OS::setsockopt(). Referenced by ACE_Ping_Socket::ACE_Ping_Socket(), open(), ACE_Pipe::open(), ACE_SOCK_Dgram_Mcast::open_i(), ACE_SOCK_Dgram::set_nic(), ACE_SOCK_Dgram_Mcast::set_option(), ACE_SOCK_Dgram_Mcast::subscribe_i(), 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_ICMP_Socket, ACE_LSOCK_Acceptor, ACE_LSOCK_CODgram, ACE_LSOCK_Dgram, ACE_LSOCK_Stream, ACE_MEM_Acceptor, ACE_MEM_IO, ACE_MEM_Stream, ACE_Ping_Socket, ACE_SOCK_Acceptor, ACE_SOCK_CODgram, ACE_SOCK_Dgram, ACE_SOCK_Dgram_Bcast, ACE_SOCK_Dgram_Mcast, ACE_SOCK_IO, ACE_SOCK_Netlink, ACE_SOCK_SEQPACK_Acceptor, ACE_SOCK_SEQPACK_Association, and ACE_SOCK_Stream. |
1.3.6