matador::socket_stream< P > Class Template Reference

#include <socket_stream.hpp>

Inherits matador::socket_base< P >.

Public Types

typedef socket_base< P > base
 
typedef base::protocol_type protocol_type
 
typedef base::peer_type peer_type
 
- Public Types inherited from matador::socket_base< P >
typedef P protocol_type
 
typedef P::peer peer_type
 

Public Member Functions

 socket_stream ()=default
 
 socket_stream (const protocol_type &protocol)
 
template<class Buffer >
ssize_t receive (Buffer &buffer)
 
template<class Buffer >
ssize_t send (const Buffer &buffer)
 
- Public Member Functions inherited from matador::socket_base< P >
 socket_base (const protocol_type &protocol)
 
 socket_base (const peer_type &peer)
 
socket_type open (const protocol_type &protocol)
 
void close ()
 
bool is_open () const
 
socket_type release ()
 
bool connect (const typename protocol_type::peer &p)
 
void non_blocking (bool nb)
 
bool non_blocking () const
 
void cloexec (bool nb)
 
bool cloexec () const
 
bool options (int name, bool value)
 
socket_type id () const
 
void assign (socket_type sock)
 

Detailed Description

template<class P>
class matador::socket_stream< P >

The class represents a read write socket. It is independent to the protocol type (UDP or TCP).

It provides to methods receive and send to read or write data to an open socket.

Template Parameters
PProtocol type of the socket

Member Typedef Documentation

◆ base

template<class P >
typedef socket_base<P> matador::socket_stream< P >::base

Shortcut to socket base class

◆ peer_type

template<class P >
typedef base::peer_type matador::socket_stream< P >::peer_type

Shortcut to the peer type

◆ protocol_type

template<class P >
typedef base::protocol_type matador::socket_stream< P >::protocol_type

Shortcut to protocol type

Constructor & Destructor Documentation

◆ socket_stream() [1/2]

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

Creates an uninitialized socket stream

◆ socket_stream() [2/2]

template<class P >
matador::socket_stream< P >::socket_stream ( const protocol_type protocol)
explicit

Creates a socket stream for the given protocol type.

Parameters
protocolType of the protocol

Member Function Documentation

◆ receive()

template<class P >
template<class Buffer >
ssize_t matador::socket_stream< P >::receive ( Buffer &  buffer)

Receives data from the underlying open socket. All received data is stored in the given buffer. The limit of the data to receive is the size of the buffer

Number of bytes is returned. If returned value is zero (0) the socket was closed. If the return value is -1 an error occurred or the socket was blocked (in case of nonblocking) The concrete error code and message can be retrieved with errno.

Template Parameters
Buffertype of the buffer object.
Parameters
bufferThe buffer object.
Returns
The number of bytes received, -1 on error or 0 on close

◆ send()

template<class P >
template<class Buffer >
ssize_t matador::socket_stream< P >::send ( const Buffer &  buffer)
Template Parameters
Buffertype of the buffer object.
Parameters
bufferThe buffer object.
Returns
The number of bytes sent, -1 on error or 0 on close

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