C++ Actor Framework 0.18
Loading...
Searching...
No Matches
Classes | Typedefs | Enumerations | Functions | Variables
caf::io::network Namespace Reference

Contains classes and functions used for network abstraction. More...

Classes

class  acceptor
 An acceptor is responsible for accepting incoming connections. More...
 
class  acceptor_impl
 A concrete acceptor with a technology-dependent policy. More...
 
class  acceptor_manager
 An acceptor manager configures an acceptor and provides callbacks for incoming connections as well as for error handling. More...
 
class  datagram_handler_impl
 A concrete datagram_handler with a technology-dependent policy. More...
 
class  datagram_manager
 A datagram manager provides callbacks for outgoing datagrams as well as for error handling. More...
 
class  datagram_servant_impl
 Default datagram servant implementation. More...
 
class  doorman_impl
 Default doorman implementation. More...
 
class  event_handler
 A socket I/O event handler. More...
 
class  interfaces
 Utility class bundling access to network interface names and addresses. More...
 
struct  ip_endpoint
 A hashable wrapper for a sockaddr storage. More...
 
class  manager
 A manager configures an I/O device and provides callbacks for various I/O operations. More...
 
class  multiplexer
 Low-level backend for IO multiplexing. More...
 
class  pipe_reader
 An event handler for the internal event pipe. More...
 
struct  protocol
 Bundles protocol information for network and transport layer communication. More...
 
class  receive_buffer
 A container that does not call constructors and destructors for its values. More...
 
class  scribe_impl
 Default scribe implementation. More...
 
class  stream
 A stream capable of both reading and writing. More...
 
class  stream_impl
 A concrete stream with a technology-dependent policy for sending and receiving data from a socket. More...
 
class  stream_manager
 A stream manager configures an IO stream and provides callbacks for incoming data as well as for error handling. More...
 

Typedefs

using address_listing = std::map< protocol::network, std::vector< std::string > >
 
using event_mask_type = short
 
using multiplexer_data = pollfd
 
using multiplexer_poll_shadow_data = std::vector< event_handler * >
 
using interfaces_map = std::map< std::string, address_listing >
 
using multiplexer_ptr = std::unique_ptr< multiplexer >
 
using setsockopt_ptr = const void *
 
using getsockopt_ptr = void *
 
using socket_send_ptr = const void *
 
using socket_recv_ptr = void *
 
using socket_size_type = unsigned
 
using signed_size_type = std::make_signed< size_t >::type
 
using native_socket = int
 

Enumerations

enum class  operation {
  read ,
  write ,
  propagate_error
}
 Identifies network IO operations, i.e., read or write.
 
enum class  rw_state {
  success ,
  failure ,
  indeterminate ,
  want_read
}
 Denotes the returned state of read and write operations on sockets. More...
 

Functions

connection_handle conn_hdl_from_socket (native_socket fd)
 
accept_handle accept_hdl_from_socket (native_socket fd)
 
CAF_IO_EXPORT expected< native_socket > new_tcp_connection (const std::string &host, uint16_t port, optional< protocol::network > preferred=none)
 
CAF_IO_EXPORT expected< native_socket > new_tcp_acceptor_impl (uint16_t port, const char *addr, bool reuse_addr)
 
expected< std::pair< native_socket, ip_endpoint > > new_remote_udp_endpoint_impl (const std::string &host, uint16_t port, optional< protocol::network > preferred=none)
 
expected< std::pair< native_socket, protocol::network > > new_local_udp_endpoint_impl (uint16_t port, const char *addr, bool reuse_addr=false, optional< protocol::network > preferred=none)
 
CAF_IO_EXPORT bool operator== (const ip_endpoint &lhs, const ip_endpoint &rhs)
 
CAF_IO_EXPORT std::string to_string (const ip_endpoint &ep)
 
CAF_IO_EXPORT std::string host (const ip_endpoint &ep)
 
CAF_IO_EXPORT uint16_t port (const ip_endpoint &ep)
 
CAF_IO_EXPORT uint32_t family (const ip_endpoint &ep)
 
CAF_IO_EXPORT error_code< secload_endpoint (ip_endpoint &ep, uint32_t &f, std::string &h, uint16_t &p, size_t &l)
 
CAF_IO_EXPORT error_code< secsave_endpoint (ip_endpoint &ep, uint32_t &f, std::string &h, uint16_t &p, size_t &l)
 
template<class Inspector >
bool inspect (Inspector &f, ip_endpoint &x)
 
int64_t int64_from_native_socket (native_socket sock)
 
CAF_IO_EXPORT int last_socket_error ()
 Returns the last socket error as an integer.
 
CAF_IO_EXPORT void close_socket (native_socket fd)
 Close socket fd.
 
CAF_IO_EXPORT bool would_block_or_temporarily_unavailable (int errcode)
 Returns true if errcode indicates that an operation would block or return nothing at the moment and can be tried again at a later point.
 
CAF_IO_EXPORT std::string last_socket_error_as_string ()
 Returns the last socket error as human-readable string.
 
CAF_IO_EXPORT std::string socket_error_as_string (int errcode)
 Returns a human-readable string for a given socket error.
 
CAF_IO_EXPORT std::pair< native_socket, native_socket > create_pipe ()
 Creates two connected sockets.
 
CAF_IO_EXPORT expected< void > child_process_inherit (native_socket fd, bool new_value)
 Sets fd to be inherited by child processes if new_value == true or not if new_value == false.
 
CAF_IO_EXPORT expected< void > keepalive (native_socket fd, bool new_value)
 Enables keepalive on fd. Throws network_error on error.
 
CAF_IO_EXPORT expected< void > nonblocking (native_socket fd, bool new_value)
 Sets fd to nonblocking if set_nonblocking == true or to blocking if set_nonblocking == false throws network_error on error.
 
CAF_IO_EXPORT expected< void > tcp_nodelay (native_socket fd, bool new_value)
 Enables or disables Nagle's algorithm on fd.
 
CAF_IO_EXPORT expected< void > allow_sigpipe (native_socket fd, bool new_value)
 Enables or disables SIGPIPE events from fd.
 
CAF_IO_EXPORT expected< void > allow_udp_connreset (native_socket fd, bool new_value)
 Enables or disables SIO_UDP_CONNRESETerror on fd.
 
CAF_IO_EXPORT expected< int > send_buffer_size (native_socket fd)
 Get the socket buffer size for fd.
 
CAF_IO_EXPORT expected< void > send_buffer_size (native_socket fd, int new_value)
 Set the socket buffer size for fd.
 
CAF_IO_EXPORT bool is_error (signed_size_type res, bool is_nonblock)
 Convenience functions for checking the result of recv or send.
 
CAF_IO_EXPORT expected< uint16_t > local_port_of_fd (native_socket fd)
 Returns the locally assigned port of fd.
 
CAF_IO_EXPORT expected< std::string > local_addr_of_fd (native_socket fd)
 Returns the locally assigned address of fd.
 
CAF_IO_EXPORT expected< uint16_t > remote_port_of_fd (native_socket fd)
 Returns the port used by the remote host of fd.
 
CAF_IO_EXPORT expected< std::string > remote_addr_of_fd (native_socket fd)
 Returns the remote host address of fd.
 
CAF_IO_EXPORT void shutdown_read (native_socket fd)
 Closes the read channel for a socket.
 
CAF_IO_EXPORT void shutdown_write (native_socket fd)
 Closes the write channel for a socket.
 
CAF_IO_EXPORT void shutdown_both (native_socket fd)
 Closes the both read and write channel for a socket.
 
std::string to_string (protocol::transport x)
 
template<class Inspector >
bool inspect (Inspector &f, protocol::transport &x)
 
std::string to_string (protocol::network x)
 
template<class Inspector >
bool inspect (Inspector &f, protocol::network &x)
 
template<class Inspector >
bool inspect (Inspector &f, protocol &x)
 
CAF_IO_EXPORT std::string to_string (const protocol &x)
 Converts a protocol into a transport/network string representation, e.g., "TCP/IPv4".
 

Variables

const event_mask_type input_mask
 Defines the bitmask for input (read) socket events.
 
const event_mask_type output_mask
 Defines the bitmask for output (write) socket events.
 
const event_mask_type error_mask
 Defines the bitmask for error socket events.
 
CAF_IO_EXPORT const int ec_out_of_memory
 
CAF_IO_EXPORT const int ec_interrupted_syscall
 
CAF_IO_EXPORT const int no_sigpipe_socket_flag
 
CAF_IO_EXPORT const int no_sigpipe_io_flag
 
constexpr native_socket invalid_native_socket = -1
 

Detailed Description

Contains classes and functions used for network abstraction.

Enumeration Type Documentation

◆ rw_state

enum class caf::io::network::rw_state
strong

Denotes the returned state of read and write operations on sockets.

Enumerator
success 

Reports that bytes could be read or written.

failure 

Reports that the socket is closed or faulty.

indeterminate 

Reports that an empty buffer is in use and no operation was performed.

want_read 

Reports that the transport wants to read data before it can write again.

Function Documentation

◆ child_process_inherit()

CAF_IO_EXPORT expected< void > caf::io::network::child_process_inherit ( native_socket  fd,
bool  new_value 
)

Sets fd to be inherited by child processes if new_value == true or not if new_value == false.

Not implemented on Windows. throws network_error on error

◆ create_pipe()

CAF_IO_EXPORT std::pair< native_socket, native_socket > caf::io::network::create_pipe ( )

Creates two connected sockets.

The former is the read handle and the latter is the write handle.

◆ tcp_nodelay()

CAF_IO_EXPORT expected< void > caf::io::network::tcp_nodelay ( native_socket  fd,
bool  new_value 
)

Enables or disables Nagle's algorithm on fd.

Exceptions
network_error