libcaf  0.14.4
Public Types | Public Member Functions | List of all members
caf::io::network::stream< Socket > Class Template Reference

A stream capable of both reading and writing. More...

#include <default_multiplexer.hpp>

Inheritance diagram for caf::io::network::stream< Socket >:
caf::io::network::event_handler

Public Types

using manager_ptr = intrusive_ptr< stream_manager >
 A smart pointer to a stream manager.
 
using buffer_type = std::vector< char >
 A buffer class providing a compatible interface to std::vector.
 
using manager_ptr = intrusive_ptr< stream_manager >
 A smart pointer to a stream manager.
 
using buffer_type = std::vector< char >
 A buffer class providing a compatible interface to std::vector. More...
 

Public Member Functions

 stream (io_backend &backend)
 
Socket & socket_handle ()
 Returns the IO socket.
 
const Socket & socket_handle () const
 
void init (Socket fd)
 Initializes this stream, setting the socket handle to fd.
 
void start (const manager_ptr &mgr)
 Starts reading data from the socket, forwarding incoming data to mgr.
 
void configure_read (receive_policy::config config)
 Configures how much data will be provided for the next consume callback. More...
 
void write (const void *buf, size_t num_bytes)
 Copies data to the write buffer. More...
 
buffer_typewr_buf ()
 Returns the write buffer of this stream. More...
 
buffer_typerd_buf ()
 
void flush (const manager_ptr &mgr)
 Sends the content of the write buffer, calling the io_failure member function of mgr in case of an error. More...
 
void stop ()
 Closes the network connection, thus stopping this stream.
 
void stop_reading ()
 
 stream (default_multiplexer &backend_ref)
 
Socket & socket_handle ()
 Returns the IO socket.
 
void init (Socket sockfd)
 Initializes this stream, setting the socket handle to fd.
 
void start (const manager_ptr &mgr)
 Starts reading data from the socket, forwarding incoming data to mgr.
 
void removed_from_loop (operation op) override
 Callback to signalize that this handler has been removed from the event loop for operations of type op. More...
 
void configure_read (receive_policy::config config)
 Configures how much data will be provided for the next consume callback. More...
 
void write (const void *buf, size_t num_bytes)
 Copies data to the write buffer. More...
 
buffer_typewr_buf ()
 Returns the write buffer of this stream. More...
 
buffer_typerd_buf ()
 
void flush (const manager_ptr &mgr)
 Sends the content of the write buffer, calling the io_failure member function of mgr in case of an error. More...
 
void stop_reading ()
 
void handle_event (operation op) override
 Returns true once the requested operation is done, i.e., to signalize the multiplexer to remove this handler. More...
 
native_socket fd () const override
 Returns the native socket handle for this handler.
 
- Public Member Functions inherited from caf::io::network::event_handler
 event_handler (default_multiplexer &dm)
 
default_multiplexer & backend ()
 Returns the multiplexer this acceptor belongs to.
 
int eventbf () const
 Returns the bit field storing the subscribed events.
 
void eventbf (int value)
 Sets the bit field storing the subscribed events.
 

Additional Inherited Members

- Protected Attributes inherited from caf::io::network::event_handler
default_multiplexer & backend_
 
int eventbf_
 

Detailed Description

template<class Socket>
class caf::io::network::stream< Socket >

A stream capable of both reading and writing.

The stream's input data is forwarded to its manager.

Member Typedef Documentation

template<class Socket >
using caf::io::network::stream< Socket >::buffer_type = std::vector<char>

A buffer class providing a compatible interface to std::vector.

Member Function Documentation

template<class Socket >
void caf::io::network::stream< Socket >::configure_read ( receive_policy::config  config)

Configures how much data will be provided for the next consume callback.

Warning
Must not be called outside the IO multiplexers event loop once the stream has been started.
template<class Socket >
void caf::io::network::stream< Socket >::configure_read ( receive_policy::config  config)

Configures how much data will be provided for the next consume callback.

Warning
Must not be called outside the IO multiplexers event loop once the stream has been started.
template<class Socket >
void caf::io::network::stream< Socket >::flush ( const manager_ptr mgr)

Sends the content of the write buffer, calling the io_failure member function of mgr in case of an error.

Warning
Must not be called outside the IO multiplexers event loop once the stream has been started.
template<class Socket >
void caf::io::network::stream< Socket >::flush ( const manager_ptr mgr)

Sends the content of the write buffer, calling the io_failure member function of mgr in case of an error.

Warning
Must not be called outside the IO multiplexers event loop once the stream has been started.
template<class Socket >
void caf::io::network::stream< Socket >::handle_event ( operation  op)
overridevirtual

Returns true once the requested operation is done, i.e., to signalize the multiplexer to remove this handler.

The handler remains in the event loop as long as it returns false.

Implements caf::io::network::event_handler.

template<class Socket >
void caf::io::network::stream< Socket >::removed_from_loop ( operation  op)
overridevirtual

Callback to signalize that this handler has been removed from the event loop for operations of type op.

Implements caf::io::network::event_handler.

template<class Socket >
buffer_type& caf::io::network::stream< Socket >::wr_buf ( )

Returns the write buffer of this stream.

Warning
Must not be modified outside the IO multiplexers event loop once the stream has been started.
template<class Socket >
buffer_type& caf::io::network::stream< Socket >::wr_buf ( )

Returns the write buffer of this stream.

Warning
Must not be modified outside the IO multiplexers event loop once the stream has been started.
template<class Socket >
void caf::io::network::stream< Socket >::write ( const void *  buf,
size_t  num_bytes 
)

Copies data to the write buffer.

Note
Not thread safe.
template<class Socket >
void caf::io::network::stream< Socket >::write ( const void *  buf,
size_t  num_bytes 
)

Copies data to the write buffer.

Warning
Not thread safe.

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