senf::ServerSocketHandle< SPolicy > Class Template Reference
[The Handle Hierarchy]

Generic SocketHandle with server interface. More...

#include <senf/Socket/ServerSocketHandle.hh>

Inheritance diagram for senf::ServerSocketHandle< SPolicy >:
Inheritance graph
[legend]

List of all members.


Detailed Description

template<class SPolicy>
class senf::ServerSocketHandle< SPolicy >

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 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)

Member Typedef Documentation

template<class SPolicy>
typedef SPolicy::AddressingPolicy::Address senf::ServerSocketHandle< SPolicy >::
Address

Address type from the addressing policy.

Definition at line 81 of file ServerSocketHandle.hh.

template<class SPolicy>
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.

template<class SPolicy>
typedef ClientSocketHandle<SPolicy> senf::ServerSocketHandle< SPolicy >::
ClientHandle

Corresponding client socket handle with the same policy.

Definition at line 90 of file ServerSocketHandle.hh.


Constructor & Destructor Documentation

template<class SPolicy >
senf::ServerSocketHandle< SPolicy >::
ServerSocketHandle ()

Definition at line 38 of file ServerSocketHandle.cti.

template<class SPolicy>
template<class OtherPolicy >
senf::ServerSocketHandle< SPolicy >::
ServerSocketHandle ( ServerSocketHandle< OtherPolicy >  other,
typename SocketHandle< SPolicy >::template IsCompatible< OtherPolicy >::type = 0 )

Definition at line 44 of file ServerSocketHandle.cti.

template<class SPolicy >
senf::ServerSocketHandle< SPolicy >::
ServerSocketHandle ( FileHandle  other,
bool  isChecked )

Definition at line 124 of file ServerSocketHandle.cti.

template<class SPolicy >
senf::ServerSocketHandle< SPolicy >::
ServerSocketHandle ( std::auto_ptr< SocketBody body )

Definition at line 51 of file ServerSocketHandle.cti.


Member Function Documentation

template<class SPolicy >
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()

Exceptions:
senf::SystemException  This variant ...
Returns:
handle of new client connection

Reimplemented in senf::ProtocolServerSocketHandle< SocketProtocol >.

Definition at line 96 of file ServerSocketHandle.cti.

template<class SPolicy >
senf::ServerSocketHandle< SPolicy >::ClientHandle senf::ServerSocketHandle< SPolicy >::
acceptfrom ( Address addr )

Accept new connection.

This variant will additionally return the remote address of the client

Parameters:
[out]  addr  address
Returns:
handle of new client connection
See also:
accept()

Definition at line 115 of file ServerSocketHandle.cti.

template<class SPolicy >
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

Returns:
std::pair with client handle and client address.
See also:
accept()

Definition at line 105 of file ServerSocketHandle.cti.

template<class SPolicy >
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.

Parameters:
[in]  addr  Local socket address to assign
Exceptions:
senf::SystemException 

Definition at line 68 of file ServerSocketHandle.cti.

template<class SPolicy >
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.

template<class SPolicy >
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.

template<class SPolicy >
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.

Parameters:
lod  level of detail requested. The interpretation of this value is protocol specific
Implementation note:
This member will be re-implemented in every derived class. See the state() documentation.

Reimplemented from senf::SocketHandle< SPolicy >.

Reimplemented in senf::ProtocolServerSocketHandle< SocketProtocol >.

Definition at line 158 of file ServerSocketHandle.cti.

template<class SPolicy >
void senf::ServerSocketHandle< SPolicy >::
listen ( unsigned  backlog = 0 )

Allow clients to connect to this server socket.

Todo:
This is very protocol specific, I don't want it in the policy interface. Especially the backlog argument seems quite protocol specific to me. However, we cannot listen() before we bind() so listen() cannot reside in the constructor. We need to find a good solution here.
Exceptions:
senf::SystemException 

Definition at line 74 of file ServerSocketHandle.cti.

template<class SPolicy >
void senf::ServerSocketHandle< SPolicy >::
local ( Address addr )

Query local address.

See also:
local()

Definition at line 89 of file ServerSocketHandle.cti.

template<class SPolicy >
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.

Exceptions:
senf::SystemException 

Definition at line 81 of file ServerSocketHandle.cti.

template<class SPolicy >
template<class OtherPolicy >
senf::SocketHandle< SPolicy >::template IsCompatible< OtherPolicy >::type const & senf::ServerSocketHandle< SPolicy >::
operator= ( ServerSocketHandle< OtherPolicy >  other )

Definition at line 58 of file ServerSocketHandle.cti.

template<class SPolicy >
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.

Parameters:
map  string to string mapping to be filled with state information
lod  level of detail requested. The interpretation of this value is protocol specific
Implementation note:
This member will be re-implemented in every derived class. This is very important since state() is not a virtual function (which we don't want since we don't want to add a vtable pointer to every handle instance).

Reimplemented from senf::SocketHandle< SPolicy >.

Reimplemented in senf::ProtocolServerSocketHandle< SocketProtocol >.

Definition at line 147 of file ServerSocketHandle.cti.


The documentation for this class was generated from the following files: