#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) |
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.
P | Protocol type of the socket |
typedef socket_base<P> matador::socket_stream< P >::base |
Shortcut to socket base class
typedef base::peer_type matador::socket_stream< P >::peer_type |
Shortcut to the peer type
typedef base::protocol_type matador::socket_stream< P >::protocol_type |
Shortcut to protocol type
|
default |
Creates an uninitialized socket stream
|
explicit |
Creates a socket stream for the given protocol type.
protocol | Type of the protocol |
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.
Buffer | type of the buffer object. |
buffer | The buffer object. |
ssize_t matador::socket_stream< P >::send | ( | const Buffer & | buffer | ) |
Buffer | type of the buffer object. |
buffer | The buffer object. |