#include <senf/Socket/ServerSocketHandle.hh>
This class provides the server side policy interface of the socket abstraction. ServerSocketHandle defines the complete policy interface. It does not implement any functionality itself however. All calls are forwarded to the following policy classes:
senf::ServerSocketHandle::bind | AddressingPolicy::bind (senf::AddressingPolicyBase) |
senf::ServerSocketHandle::listen | CommunicationPolicy::listen (senf::CommunicationPolicyBase) |
senf::ServerSocketHandle::local | AddressingPolicy::local (senf::AddressingPolicyBase) |
senf::ServerSocketHandle::accept | CommunicationPolicy::accept (senf::CommunicationPolicyBase) |
senf::ServerSocketHandle::acceptfrom | CommunicationPolicy::accept (senf::CommunicationPolicyBase) |
A ServerSocketHandle is only meaningful for connection oriented addressable protocols (CommunicationPolicy is ConnectedCommunicationPolicy and AddressingPolicy is not NoAddressingPolicy).
It is important to note, that not all members are always accessible. Which are depends on the Policy
template argument. If any of the policy axis is left unspecified the corresponding members will not be callable (you will get a compile time error). Even if every policy axis is defined, some members might (and will) not exist if they are meaningless for the protocol of the socket. This depends on the exact policy.
To find out, which members are available, you have to check the documentation of the policy classes. You can also find a summary of all members available in the leaf protocol class documentation.
Definition at line 73 of file ServerSocketHandle.hh.
Public Types |
|
typedef SPolicy::AddressingPolicy::Address |
Address |
Address type from the addressing policy. |
|
typedef boost::call_traits < Address >::param_type |
AddressParam |
'Best' type for passing address as parameter |
|
typedef ClientSocketHandle < SPolicy > |
ClientHandle |
Corresponding client socket handle with the same policy. |
|
Public Member Functions |
|
void | state (SocketStateMap &map, unsigned lod=0) |
Inquire state information of socket handle. |
|
std::string | dumpState (unsigned lod=0) |
Format complete state information as string. |
|
Static Public Member Functions |
|
static ServerSocketHandle | cast_static (FileHandle handle) |
static ServerSocketHandle | cast_dynamic (FileHandle handle) |
Structors and default members |
|
ServerSocketHandle () | |
template<class OtherPolicy > | |
ServerSocketHandle (ServerSocketHandle< OtherPolicy > other, typename SocketHandle< SPolicy >::template IsCompatible< OtherPolicy >::type *=0) | |
template<class OtherPolicy > | |
SocketHandle< SPolicy > ::template IsCompatible < OtherPolicy >::type const & |
operator= (ServerSocketHandle< OtherPolicy > other) |
Server socket interface |
|
void | bind (AddressParam addr) |
Set local address. |
|
void | listen (unsigned backlog=0) |
Allow clients to connect to this server socket. |
|
Address | local () |
Query local address. |
|
void | local (Address &addr) |
Query local address. |
|
ClientHandle | accept () |
Accept new connection. |
|
std::pair< ClientHandle, Address > | acceptfrom () |
Accept new connection. |
|
ClientHandle | acceptfrom (Address &addr) |
Accept new connection. |
|
Protected Member Functions |
|
ServerSocketHandle (FileHandle other, bool isChecked) | |
ServerSocketHandle (std::auto_ptr< SocketBody > body) |
typedef SPolicy::AddressingPolicy::Address senf::ServerSocketHandle< SPolicy >:: | ||||
Address | ||||
Address type from the addressing policy.
Definition at line 81 of file ServerSocketHandle.hh.
typedef boost::call_traits<Address>::param_type senf::ServerSocketHandle< SPolicy >:: | ||||
AddressParam | ||||
'Best' type for passing address as parameter
Depending on the type of Address
, this will be either Address
or Address const &
. See call_traits documentation in the Boost.Utility library.
Definition at line 88 of file ServerSocketHandle.hh.
typedef ClientSocketHandle<SPolicy> senf::ServerSocketHandle< SPolicy >:: | ||||
ClientHandle | ||||
Corresponding client socket handle with the same policy.
Definition at line 90 of file ServerSocketHandle.hh.
senf::ServerSocketHandle< SPolicy >:: | ||||
ServerSocketHandle | () | |||
Definition at line 38 of file ServerSocketHandle.cti.
senf::ServerSocketHandle< SPolicy >:: | ||||
ServerSocketHandle | ( | ServerSocketHandle< OtherPolicy > | other, | |
typename SocketHandle< SPolicy >::template IsCompatible< OtherPolicy >::type * | = 0
|
) | ||
Definition at line 44 of file ServerSocketHandle.cti.
senf::ServerSocketHandle< SPolicy >:: | ||||
ServerSocketHandle | ( | FileHandle | other, | |
bool | isChecked | ) | ||
Definition at line 124 of file ServerSocketHandle.cti.
senf::ServerSocketHandle< SPolicy >:: | ||||
ServerSocketHandle | ( | std::auto_ptr< SocketBody > | body | ) |
Definition at line 51 of file ServerSocketHandle.cti.
senf::ServerSocketHandle< SPolicy >::ClientHandle senf::ServerSocketHandle< SPolicy >:: | ||||
accept | () | |||
Accept new connection.
If the handle is non-blocking, accept will NOT block. If no connection is available to be returned, accept will return a ClientSocketHandle which is not valid()
senf::SystemException | This variant ... |
Reimplemented in senf::ProtocolServerSocketHandle< SocketProtocol >.
Definition at line 96 of file ServerSocketHandle.cti.
senf::ServerSocketHandle< SPolicy >::ClientHandle senf::ServerSocketHandle< SPolicy >:: | ||||
acceptfrom | ( | Address & | addr | ) |
Accept new connection.
This variant will additionally return the remote address of the client
[out] | addr | address |
Definition at line 115 of file ServerSocketHandle.cti.
std::pair< typename senf::ServerSocketHandle< SPolicy >::ClientHandle, typename senf::ServerSocketHandle< SPolicy >::Address > senf::ServerSocketHandle< SPolicy >:: | ||||
acceptfrom | () | |||
Accept new connection.
This variant will additionally return the remote address of the client
std::pair
with client handle and client address.Definition at line 105 of file ServerSocketHandle.cti.
void senf::ServerSocketHandle< SPolicy >:: | ||||
bind | ( | AddressParam | addr | ) |
Set local address.
For addressable protocols (AddressingPolicy is not NoAddressingPolicy), bind() will set the local address of the socket.
[in] | addr | Local socket address to assign |
senf::SystemException |
Definition at line 68 of file ServerSocketHandle.cti.
senf::ServerSocketHandle< SPolicy > senf::ServerSocketHandle< SPolicy >:: | ||||
cast_dynamic | ( | FileHandle | handle | ) |
For internal use only.
Reimplemented from senf::SocketHandle< SPolicy >.
Reimplemented in senf::ProtocolServerSocketHandle< SocketProtocol >.
Definition at line 138 of file ServerSocketHandle.cti.
senf::ServerSocketHandle< SPolicy > senf::ServerSocketHandle< SPolicy >:: | ||||
cast_static | ( | FileHandle | handle | ) |
For internal use only.
Reimplemented from senf::SocketHandle< SPolicy >.
Reimplemented in senf::ProtocolServerSocketHandle< SocketProtocol >.
Definition at line 131 of file ServerSocketHandle.cti.
std::string senf::ServerSocketHandle< SPolicy >:: | ||||
dumpState | ( | unsigned |
lod = 0
|
) |
Format complete state information as string.
Formats the complete state map value and returns it as a single multi-line string.
lod | level of detail requested. The interpretation of this value is protocol specific |
Reimplemented from senf::SocketHandle< SPolicy >.
Reimplemented in senf::ProtocolServerSocketHandle< SocketProtocol >.
Definition at line 158 of file ServerSocketHandle.cti.
void senf::ServerSocketHandle< SPolicy >:: | ||||
listen | ( | unsigned |
backlog = 0
|
) |
Allow clients to connect to this server socket.
senf::SystemException |
Definition at line 74 of file ServerSocketHandle.cti.
void senf::ServerSocketHandle< SPolicy >:: | ||||
local | ( | Address & | addr | ) |
senf::ServerSocketHandle< SPolicy >::Address senf::ServerSocketHandle< SPolicy >:: | ||||
local | () | |||
Query local address.
This member will return the address of the local socket in addressable protocols (AddressingPolicy is not NoAddressingPolicy).
There are two Variants of this member, one will return the address by value, the other takes a reference argument to elide the copy operation.
senf::SystemException |
Definition at line 81 of file ServerSocketHandle.cti.
senf::SocketHandle< SPolicy >::template IsCompatible< OtherPolicy >::type const & senf::ServerSocketHandle< SPolicy >:: | ||||
operator= | ( | ServerSocketHandle< OtherPolicy > | other | ) |
Definition at line 58 of file ServerSocketHandle.cti.
void senf::ServerSocketHandle< SPolicy >:: | ||||
state | ( | SocketStateMap & | map, | |
unsigned |
lod = 0
|
) | ||
Inquire state information of socket handle.
The map argument (a string to string mapping) will be filled with information covering the current state of the socket. The information provided depends on the socket protocol. The amount of information returned can be controlled using the lod
value.
See senf::SocketProtocol::state() for more information, how the Information is generated.
map | string to string mapping to be filled with state information | |
lod | level of detail requested. The interpretation of this value is protocol specific |
Reimplemented from senf::SocketHandle< SPolicy >.
Reimplemented in senf::ProtocolServerSocketHandle< SocketProtocol >.
Definition at line 147 of file ServerSocketHandle.cti.