Generic SocketHandle with server interface. More...
#include <senf/Socket/ClientSocketHandle.hh>
Public Types | |
typedef SPolicy::AddressingPolicy::Address | Address |
Address type from the addressing policy. More... | |
typedef boost::call_traits< Address >::param_type | AddressParam |
'Best' type for passing address as parameter More... | |
typedef ClientSocketHandle< SPolicy > | ClientHandle |
Corresponding client socket handle with the same policy. More... | |
Public Types inherited from senf::SocketHandle< SPolicy > | |
typedef SPolicy | Policy |
Public Member Functions | |
void | state (SocketStateMap &map, unsigned lod=0) |
std::string | dumpState (unsigned lod=0) |
Public Member Functions inherited from senf::SocketHandle< SPolicy > | |
template<class OtherPolicy > | |
IsCompatible< OtherPolicy >::type const & | operator= (SocketHandle< OtherPolicy > other) |
Assign from other socket handle checking policy compatibility. More... | |
void | state (SocketStateMap &map, unsigned lod=0) |
Inquire state information of socket handle. More... | |
std::string | dumpState (unsigned lod=0) |
Format complete state information as string. More... | |
template<class Facet > | |
Facet & | facet () |
Access a protocol facet. More... | |
SocketHandle () | |
template<class OtherPolicy > | |
SocketHandle (SocketHandle< OtherPolicy > other, typename IsCompatible< OtherPolicy >::type *=0) | |
Convert from other socket handle checking policy compatibility. More... | |
Public Member Functions inherited from senf::FileHandle | |
void | close () |
Close filehandle. More... | |
void | terminate () |
Close filehandle ignoring error conditions. More... | |
bool | readable () const |
Check, whether a read on the handle would not block (ignoring blocking state) More... | |
bool | waitReadable (senf::ClockService::clock_type timeout=senf::ClockService::clock_type(-1)) const |
Wait, until read on the handle would not block (ignoring blocking state) More... | |
bool | writeable () const |
Check, whether a write on the handle would not block (ignoring blocking state) More... | |
bool | waitWriteable (senf::ClockService::clock_type timeout=senf::ClockService::clock_type(-1)) const |
Wait, until a write on the handle would not block (ignoring blocking state) More... | |
bool | oobReadable () const |
Check, whether a read of prioritized data on the handle would not block (ignoring blocking state) More... | |
bool | waitOOBReadable (senf::ClockService::clock_type timeout=senf::ClockService::clock_type(-1)) const |
Wait, until read of prioritized data on the handle does not block (ignoring blocking state) More... | |
bool | blocking () const |
Return current blocking state. More... | |
void | blocking (bool status) |
Set blocking state. More... | |
bool | eof () const |
Check EOF condition. More... | |
bool | valid () const |
Check filehandle validity. More... | |
bool | boolean_test () const |
Short for valid() && ! eof() More... | |
int | fd () const |
Return the raw FileHandle. More... | |
int | refcount () const |
bool | is_shared () const |
FileHandle () | |
~FileHandle () | |
Public Member Functions inherited from senf::comparable_safe_bool< class > | |
operator bool_type () const | |
bool | operator! () const |
Static Public Member Functions | |
static ServerSocketHandle | cast_static (FileHandle handle) |
static ServerSocketHandle | cast_dynamic (FileHandle handle) |
Static Public Member Functions inherited from senf::SocketHandle< SPolicy > | |
static SocketHandle | cast_static (FileHandle handle) |
static SocketHandle | cast_dynamic (FileHandle handle) |
Static Public Member Functions inherited from senf::FileHandle | |
static FileHandle | cast_static (FileHandle handle) |
static FileHandle | cast_dynamic (FileHandle handle) |
Protected Member Functions | |
ServerSocketHandle (FileHandle other, bool isChecked) | |
ServerSocketHandle (std::unique_ptr< SocketBody > body) | |
Protected Member Functions inherited from senf::SocketHandle< SPolicy > | |
SocketHandle (std::unique_ptr< SocketBody > body) | |
Initialize SocketHandle providing the protocol. More... | |
SocketHandle (FileHandle other, bool isChecked) | |
Initialize SocketHandle from arbitrary checked FileHandle. More... | |
SocketBody & | body () |
Access socket body. More... | |
SocketBody const & | body () const |
Access socket body in const context. More... | |
SocketProtocol & | protocol () const |
Access protocol class. More... | |
void | assign (FileHandle other) |
Protected Member Functions inherited from senf::FileHandle | |
FileHandle (std::unique_ptr< FileBody > body) | |
create new FileHandle instance More... | |
FileHandle (FileBody::ptr body) | |
FileBody & | body () |
Access body. More... | |
FileBody const & | body () const |
Access body in const context. More... | |
void | fd (int fd) |
Set raw filehandle. More... | |
void * | extraPtr () const |
get extra data pointer More... | |
void | extraPtr (void *ptr) |
set extra data pointer More... | |
Protected Member Functions inherited from senf::comparable_safe_bool< class > | |
~comparable_safe_bool () | |
Protected Member Functions inherited from senf::safe_bool_base | |
void | this_type_does_not_support_comparisons () const |
safe_bool_base () | |
safe_bool_base (const safe_bool_base &) | |
safe_bool_base & | operator= (const safe_bool_base &) |
~safe_bool_base () | |
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. More... | |
void | listen (unsigned backlog=0) |
Allow clients to connect to this server socket. More... | |
Address | local () |
Query local address. More... | |
void | local (Address &addr) |
Query local address. More... | |
ClientHandle | accept () |
Accept new connection. More... | |
std::pair< ClientHandle, Address > | acceptfrom () |
Accept new connection. More... | |
ClientHandle | acceptfrom (Address &addr) |
Accept new connection. More... | |
Additional Inherited Members | |
Protected Types inherited from senf::safe_bool_base | |
typedef void(safe_bool_base::* | bool_type) () const |
Static Protected Member Functions inherited from senf::FileHandle | |
static FileBody & | body (FileHandle &handle) |
Access body of another FileHandle instance. More... | |
static FileBody const & | body (FileHandle const &handle) |
Access body of another FileHandle instance in const context. More... | |
Related Functions inherited from senf::SocketHandle< SPolicy > | |
template<class SPolicy > | |
std::ostream & | operator<< (std::ostream &os, SocketHandle< SPolicy > handle) |
Write stream status dump to output stream. More... | |
template<class Target , class Source > | |
Target | static_socket_cast (Source handle) |
static socket (down-)cast More... | |
template<class Target , class Source > | |
Target | dynamic_socket_cast (Source handle) |
dynamic socket (down-)cast More... | |
template<class Target , class Source > | |
bool | check_socket_cast (Source handle) |
dynamically check cast validity More... | |
Related Functions inherited from senf::FileHandle | |
int | retrieve_filehandle (FileHandle handle) |
Adapt FileHandle to senf::scheduler. More... | |
Generic SocketHandle with server interface.
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 36 of file ClientSocketHandle.hh.
typedef SPolicy::AddressingPolicy::Address senf::ServerSocketHandle< SPolicy >::Address |
Address type from the addressing policy.
Definition at line 72 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 79 of file ServerSocketHandle.hh.
typedef ClientSocketHandle<SPolicy> senf::ServerSocketHandle< SPolicy >::ClientHandle |
Corresponding client socket handle with the same policy.
Definition at line 81 of file ServerSocketHandle.hh.
senf::ServerSocketHandle< SPolicy >::ServerSocketHandle | ( | ) |
senf::ServerSocketHandle< SPolicy >::ServerSocketHandle | ( | ServerSocketHandle< OtherPolicy > | other, |
typename SocketHandle< SPolicy >::template IsCompatible< OtherPolicy >::type * | = 0 |
||
) |
|
protected |
|
explicitprotected |
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 ... |
std::pair<ClientHandle, 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. ClientHandle senf::ServerSocketHandle< SPolicy >::acceptfrom | ( | Address & | addr | ) |
Accept new connection.
This variant will additionally return the remote address of the client
[out] | addr | address |
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 |
|
static |
|
static |
std::string senf::ServerSocketHandle< SPolicy >::dumpState | ( | unsigned | lod = 0 | ) |
void senf::ServerSocketHandle< SPolicy >::listen | ( | unsigned | backlog = 0 | ) |
Allow clients to connect to this server socket.
senf::SystemException |
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 |
void senf::ServerSocketHandle< SPolicy >::local | ( | Address & | addr | ) |
Query local address.
SocketHandle<SPolicy>::template IsCompatible<OtherPolicy>::type const& senf::ServerSocketHandle< SPolicy >::operator= | ( | ServerSocketHandle< OtherPolicy > | other | ) |
void senf::ServerSocketHandle< SPolicy >::state | ( | SocketStateMap & | map, |
unsigned | lod = 0 |
||
) |