#include <senf/Socket/SocketHandle.hh>
The senfSocketHandle class introduces the two abstraction layers of the socket library. senf::SocketHandle does not provide socket functions it only provides the infrastructure necessary to support both, the protocol and the policy interface.
SocketHandle takes the socket policy as a template argument. SocketHandle also introduces the protocol class. However, the class has no public constructors (see the derived classes senf::ProtocolClientSocketHandle and senf::ProtocolServerSocketHandle).
The most important functionality provided by SocketHandle is the conversion constructor. This allows to implicitly convert between compatible socket handle types as specified by the socket policy. The conversion constructor is defined in such a way, that only valid conversions are possible (see the implementation source for a more complete discussion).
SPolicy | socket policy |
Definition at line 69 of file SocketHandle.hh.
Classes |
|
struct | IsCompatible |
Check policy compatibility. More... |
|
Public Types |
|
typedef SPolicy | Policy |
Public Member Functions |
|
template<class OtherPolicy > | |
IsCompatible< OtherPolicy > ::type const & |
operator= (SocketHandle< OtherPolicy > other) |
Assign from other socket handle checking policy < compatibility. |
|
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. |
|
template<class Facet > | |
Facet & | facet () |
Access a protocol facet. |
|
Static Public Member Functions |
|
static SocketHandle | cast_static (FileHandle handle) |
static SocketHandle | cast_dynamic (FileHandle handle) |
Related Functions |
|
(Note that these are not member functions.) |
|
template<class SPolicy > | |
std::ostream & | operator<< (std::ostream &os, SocketHandle< SPolicy > handle) |
Write stream status dump to output stream. |
|
template<class Target , class Source > | |
Target | static_socket_cast (Source handle) |
static socket (down-)cast |
|
template<class Target , class Source > | |
Target | dynamic_socket_cast (Source handle) |
dynamic socket (down-)cast |
|
template<class Target , class Source > | |
bool | check_socket_cast (Source handle) |
dynamically check cast validity |
|
Structors and default members |
|
SocketHandle () | |
template<class OtherPolicy > | |
SocketHandle (SocketHandle< OtherPolicy > other, typename IsCompatible< OtherPolicy >::type *=0) | |
Convert from other socket handle checking policy < compatibility. |
|
Protected Member Functions |
|
SocketHandle (std::auto_ptr< SocketBody > body) | |
Initialize SocketHandle providing the protocol. |
|
SocketHandle (FileHandle other, bool isChecked) | |
Initialize SocketHandle from arbitrary checked < FileHandle. |
|
SocketBody & | body () |
Access socket body. |
|
SocketBody const & | body () const |
Access socket body in const context. |
|
SocketProtocol & | protocol () const |
Access protocol class. |
|
void | assign (FileHandle other) |
typedef SPolicy senf::SocketHandle< SPolicy >:: | ||||
Policy | ||||
Definition at line 76 of file SocketHandle.hh.
senf::SocketHandle< SPolicy >:: | ||||
SocketHandle | () | |||
Definition at line 41 of file SocketHandle.cti.
senf::SocketHandle< SPolicy >:: | ||||
SocketHandle | ( | SocketHandle< OtherPolicy > | other, | |
typename IsCompatible< OtherPolicy >::type * | = 0
|
) | ||
Convert from other socket handle checking policy < compatibility.
Definition at line 46 of file SocketHandle.cti.
senf::SocketHandle< SPolicy >:: | ||||
SocketHandle | ( | std::auto_ptr< SocketBody > | body | ) |
Initialize SocketHandle providing the protocol.
protocol | Protocol class of the protocol implemented by this socket handle | |
isServer |
true , if this SobcketHandle instance implements a server handle, false otherwise |
Definition at line 62 of file SocketHandle.cti.
senf::SocketHandle< SPolicy >:: | ||||
SocketHandle | ( | FileHandle | other, | |
bool | isChecked | ) | ||
Initialize SocketHandle from arbitrary checked < FileHandle.
This constructor is used to support up- and downcasting of SocketHandle instances.
other | FileHandle to assign | |
isChecked | has to be true
|
isChecked
parameter ??Definition at line 67 of file SocketHandle.cti.
void senf::SocketHandle< SPolicy >:: | ||||
assign | ( | FileHandle | other | ) |
For internal use only.
Definition at line 100 of file SocketHandle.cti.
senf::SocketBody const & senf::SocketHandle< SPolicy >:: | ||||
body | () | |||
Access socket body in const context.
This member replaces the corresponding FileHandle member and returns an appropriately cast body reference
Reimplemented from senf::FileHandle.
Definition at line 84 of file SocketHandle.cti.
senf::SocketBody & senf::SocketHandle< SPolicy >:: | ||||
body | () | |||
Access socket body.
This member replaces the corresponding FileHandle member and returns an appropriately cast body reference
Reimplemented from senf::FileHandle.
Definition at line 76 of file SocketHandle.cti.
senf::SocketHandle< SPolicy > senf::SocketHandle< SPolicy >:: | ||||
cast_dynamic | ( | FileHandle | handle | ) |
For internal use only.
Reimplemented from senf::FileHandle.
Reimplemented in senf::ClientSocketHandle< SPolicy >, senf::ProtocolClientSocketHandle< SocketProtocol >, senf::ProtocolServerSocketHandle< SocketProtocol >, senf::ServerSocketHandle< SPolicy >, senf::ClientSocketHandle< DVBFrontendSocketProtocol::Policy >, senf::ClientSocketHandle< SocketProtocol::Policy >, senf::ProtocolClientSocketHandle< DVBFrontendSocketProtocol >, and senf::ServerSocketHandle< SocketProtocol::Policy >.
Definition at line 114 of file SocketHandle.cti.
senf::SocketHandle< SPolicy > senf::SocketHandle< SPolicy >:: | ||||
cast_static | ( | FileHandle | handle | ) |
For internal use only.
Reimplemented from senf::FileHandle.
Reimplemented in senf::ClientSocketHandle< SPolicy >, senf::ProtocolClientSocketHandle< SocketProtocol >, senf::ProtocolServerSocketHandle< SocketProtocol >, senf::ServerSocketHandle< SPolicy >, senf::ClientSocketHandle< DVBFrontendSocketProtocol::Policy >, senf::ClientSocketHandle< SocketProtocol::Policy >, senf::ProtocolClientSocketHandle< DVBFrontendSocketProtocol >, and senf::ServerSocketHandle< SocketProtocol::Policy >.
Definition at line 107 of file SocketHandle.cti.
std::string senf::SocketHandle< 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 in senf::ClientSocketHandle< SPolicy >, senf::ProtocolClientSocketHandle< SocketProtocol >, senf::ProtocolServerSocketHandle< SocketProtocol >, senf::ServerSocketHandle< SPolicy >, senf::ClientSocketHandle< DVBFrontendSocketProtocol::Policy >, senf::ClientSocketHandle< SocketProtocol::Policy >, senf::ProtocolClientSocketHandle< DVBFrontendSocketProtocol >, and senf::ServerSocketHandle< SocketProtocol::Policy >.
Definition at line 190 of file SocketHandle.cti.
Access a protocol facet.
This member will try to access the given protocol facet of the socket. If Facet is a valid facet of the protocol, it is returned, otherwise std::bad_cast
will be thrown.
std::bad_cast | if Facet is not a protocol facet of this socket |
Definition at line 199 of file SocketHandle.cti.
senf::SocketHandle< SPolicy >::template IsCompatible< OtherPolicy >::type const & senf::SocketHandle< SPolicy >:: | ||||
operator= | ( | SocketHandle< OtherPolicy > | other | ) |
Assign from other socket handle checking policy < compatibility.
Definition at line 54 of file SocketHandle.cti.
senf::SocketProtocol & senf::SocketHandle< SPolicy >:: | ||||
protocol | () | |||
Access protocol class.
Definition at line 93 of file SocketHandle.cti.
void senf::SocketHandle< 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 in senf::ClientSocketHandle< SPolicy >, senf::ProtocolClientSocketHandle< SocketProtocol >, senf::ProtocolServerSocketHandle< SocketProtocol >, senf::ServerSocketHandle< SPolicy >, senf::ClientSocketHandle< DVBFrontendSocketProtocol::Policy >, senf::ClientSocketHandle< SocketProtocol::Policy >, senf::ProtocolClientSocketHandle< DVBFrontendSocketProtocol >, and senf::ServerSocketHandle< SocketProtocol::Policy >.
Definition at line 174 of file SocketHandle.cti.