senf::BSDAddressingPolicyMixin< Address > Struct Template Reference

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

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

Inheritance diagram for senf::BSDAddressingPolicyMixin< Address >:

Static Public Member Functions

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

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 75 of file BSDAddressingPolicy.hh.

Member Function Documentation

◆ bind()

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

Set local socket address.

Parameters
[in]handlesocket handle
[in]addrlocal socket address

◆ connect()

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

Connect to remote host.

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

Parameters
[in]handlesocket handle
[in]addraddress of remote peer to connect to

◆ local()

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

Return local of socket.

Parameters
[in]handlesocket handle to check
[out]addrlocal socket address

◆ peer()

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

Return address of remote peer on connected sockets.

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

Parameters
[in]handlesocket handle to get peer address of
[out]addraddress of remote peer

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