matador::peer_base< P > Class Template Reference

#include <peer.hpp>

Public Types

typedef P protocol_type
 

Public Member Functions

 peer_base ()=default
 
 peer_base (address addr)
 
 peer_base (address addr, unsigned short port)
 
 peer_base (const peer_base &x)
 
 peer_base (peer_base &&x) noexcept
 
peer_baseoperator= (const peer_base &x)
 
peer_baseoperator= (peer_base &&x) noexcept
 
 ~peer_base ()=default
 
int port () const
 
protocol_type protocol () const
 
sockaddr * data ()
 
const sockaddr * data () const
 
size_t size () const
 
addressaddr ()
 
const addressaddr () const
 
std::string to_string () const
 

Detailed Description

template<class P>
class matador::peer_base< P >

The peer_base class acts like the holder of network endpoint information like socket address and port. The template argument sets the protocol type either TCP or UDP.

Template Parameters
PProtocol type

Member Typedef Documentation

◆ protocol_type

template<class P >
typedef P matador::peer_base< P >::protocol_type

Short to protocol type

Constructor & Destructor Documentation

◆ peer_base() [1/5]

template<class P >
matador::peer_base< P >::peer_base ( )
default

Default constructor

◆ peer_base() [2/5]

template<class P >
matador::peer_base< P >::peer_base ( address  addr)
inlineexplicit

Creates a peer from a given address. Port is set to zero.

Parameters
addrAddress to create the peer from

◆ peer_base() [3/5]

template<class P >
matador::peer_base< P >::peer_base ( address  addr,
unsigned short  port 
)
inline

Creates a peer from a given address and port

Parameters
addrAddress to create the peer from
portPort of the endpoint

◆ peer_base() [4/5]

template<class P >
matador::peer_base< P >::peer_base ( const peer_base< P > &  x)
inline

Copy creates a peer from the given peer

Parameters
xPeer to copy from

◆ peer_base() [5/5]

template<class P >
matador::peer_base< P >::peer_base ( peer_base< P > &&  x)
inlinenoexcept

Move creates a peer from a given peer

Parameters
xPeer to move from

◆ ~peer_base()

template<class P >
matador::peer_base< P >::~peer_base ( )
default

Destructor

Member Function Documentation

◆ addr() [1/2]

template<class P >
address & matador::peer_base< P >::addr ( )
inline

Returns a reference to the address

Returns
A reference to the address

◆ addr() [2/2]

template<class P >
const address & matador::peer_base< P >::addr ( ) const
inline

Returns a reference to the address

Returns
A reference to the address

◆ data() [1/2]

template<class P >
sockaddr * matador::peer_base< P >::data ( )
inline

Returns the raw pointer to the sockaddr structure

Returns
The raw pointer to the sockaddr structure

◆ data() [2/2]

template<class P >
const sockaddr * matador::peer_base< P >::data ( ) const
inline

Returns the raw pointer to the sockaddr structure

Returns
The raw pointer to the sockaddr structure

◆ operator=() [1/2]

template<class P >
peer_base & matador::peer_base< P >::operator= ( const peer_base< P > &  x)
inline

Copy assigns a given peer to this peer

Parameters
xPeer to assign
Returns
The assigned peer

◆ operator=() [2/2]

template<class P >
peer_base & matador::peer_base< P >::operator= ( peer_base< P > &&  x)
inlinenoexcept

Assign moves the given peer to this peer

Parameters
xThe peer to move assign
Returns
The moved peer

◆ port()

template<class P >
int matador::peer_base< P >::port ( ) const
inline

Returns the current port of the peer.

Returns
The current port

◆ protocol()

template<class P >
protocol_type matador::peer_base< P >::protocol ( ) const
inline

Returns the current IP protocol of the peer address which is either IPv4 or IPv6

Returns
The current IP protocol

◆ size()

template<class P >
size_t matador::peer_base< P >::size ( ) const
inline

Returns the size of the underlying sockaddr structure

Returns
The size of the underlying sockaddr structure

◆ to_string()

template<class P >
std::string matador::peer_base< P >::to_string ( ) const
inline

Converts the peer endpoint to a string in the format [ip]:[port]

Returns
Returns a string representation of the peer

The documentation for this class was generated from the following file:
  • matador/net/peer.hpp