senf::BSDAddressingPolicyMixin< Address > Struct Template Reference
[Policy Implementation classes]

Template for generic AddressingPolicy implementation based on the BSD socket API. More...

#include <senf/Socket/Protocols/BSDAddressingPolicy.hh>

Inheritance diagram for senf::BSDAddressingPolicyMixin< Address >:
Inheritance graph
[legend]

List of all members.


Detailed Description

template<class Address>
struct senf::BSDAddressingPolicyMixin< Address >

Template for generic AddressingPolicy implementation based on the BSD socket API.

This template provides an implementation template to implement generic addressing policy classes which rely on the standard BSD socket API for their implementation (connect/bind/getsockname/getpeername).

The Address template parameter specifies the address type of the addressing policy. This type must have two members: sockaddr_p() and socklen(). The first must return a struct sockaddr * to the address, the second must return the size of the address in bytes. The pointer returned by sockaddr_p() must be non-const if called on a non-const address. The underlying socket address stored at that pointer might be modified.

This template class is inherited into addressing policy classes via private inheritance. Then the members supported by the respective addressing policy are made available via using declarations (See INet4AddressingPolicy for an Example).

Idea:
We could explicitly provide open_sockaddr_p() and close_sockaddr_p() members. sockaddr_p could always return a const * whereas open_sockaddr_p should return a non-const pointer. The close operation would then explicitly signal, that the new value should be incorporated into the class. With our current implementation, the close member would be a no-op, however this should free us from using the sockaddr values as a direct storage representation of the address.

Definition at line 84 of file BSDAddressingPolicy.hh.


Static Public Member Functions

template<class SPolicy >
static void  peer (SocketHandle< SPolicy > const &handle, Address &addr)
  Return address of remote peer on connected sockets.
static void  local (FileHandle const &handle, Address &addr)
  Return local of socket.
template<class SPolicy >
static void  connect (SocketHandle< SPolicy > const &handle, Address const &addr)
  Connect to remote host.
static void  bind (FileHandle const &handle, Address const &addr)
  Set local socket address.

Member Function Documentation

template<class Address>
void senf::BSDAddressingPolicyMixin< Address >::
bind ( FileHandle const &  handle,
Address const &  addr )

Set local socket address.

Parameters:
[in]  handle  socket handle
[in]  addr  local socket address

Definition at line 95 of file BSDAddressingPolicy.cti.

template<class Address>
template<class SPolicy >
void senf::BSDAddressingPolicyMixin< Address >::
connect ( SocketHandle< SPolicy > const &  handle,
Address const &  addr )

Connect to remote host.

This member is only available if the socket handles communication policy is ConnectedCommunicationPolicy.

Parameters:
[in]  handle  socket handle
[in]  addr  address of remote peer to connect to

Definition at line 77 of file BSDAddressingPolicy.cti.

template<class Address>
void senf::BSDAddressingPolicyMixin< Address >::
local ( FileHandle const &  handle,
Address &  addr )

Return local of socket.

Parameters:
[in]  handle  socket handle to check
[out]  addr  local socket address

Definition at line 82 of file BSDAddressingPolicy.cti.

template<class Address>
template<class SPolicy >
void senf::BSDAddressingPolicyMixin< Address >::
peer ( SocketHandle< SPolicy > const &  handle,
Address &  addr )

Return address of remote peer on connected sockets.

This member is only available if the socket handles communication policy is ConnectedCommunicationPolicy.

Parameters:
[in]  handle  socket handle to get peer address of
[out]  addr  address of remote peer

Definition at line 55 of file BSDAddressingPolicy.cti.


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