Seastar
High performance C++ framework for concurrent servers
|
A TCP (or other stream-based protocol) connection.
A connected_socket
represents a full-duplex stream between two endpoints, a local endpoint and a remote endpoint.
#include <seastar/net/api.hh>
Public Member Functions | |
connected_socket () noexcept | |
Constructs a connected_socket not corresponding to a connection. | |
connected_socket (connected_socket &&cs) noexcept | |
Moves a connected_socket object. | |
connected_socket & | operator= (connected_socket &&cs) noexcept |
Move-assigns a connected_socket object. | |
input_stream< char > | input (connected_socket_input_stream_config csisc={}) |
output_stream< char > | output (size_t buffer_size=8192) |
void | set_nodelay (bool nodelay) |
Sets the TCP_NODELAY option (disabling Nagle's algorithm) | |
bool | get_nodelay () const |
void | set_keepalive (bool keepalive) |
Sets SO_KEEPALIVE option (enable keepalive timer on a socket) | |
bool | get_keepalive () const |
void | set_keepalive_parameters (const net::keepalive_params &p) |
Sets TCP keepalive parameters. | |
net::keepalive_params | get_keepalive_parameters () const |
Get TCP keepalive parameters. | |
void | set_sockopt (int level, int optname, const void *data, size_t len) |
int | get_sockopt (int level, int optname, void *data, size_t len) const |
socket_address | local_address () const noexcept |
Local address of the socket. | |
socket_address | remote_address () const noexcept |
Remote address of the socket. | |
void | shutdown_output () |
void | shutdown_input () |
operator bool () const noexcept | |
future | wait_input_shutdown () |
bool seastar::connected_socket::get_keepalive | ( | ) | const |
Gets O_KEEPALIVE option
bool seastar::connected_socket::get_nodelay | ( | ) | const |
Gets the TCP_NODELAY option (Nagle's algorithm)
int seastar::connected_socket::get_sockopt | ( | int | level, |
int | optname, | ||
void * | data, | ||
size_t | len | ||
) | const |
Gets custom socket options. Based on getsockopt function. Linux users should refer to protocol-specific manuals to see available options, e.g. tcp(7), ip(7), etc.
input_stream< char > seastar::connected_socket::input | ( | connected_socket_input_stream_config | csisc = {} | ) |
Gets the input stream.
csisc | Configuration for the input_stream returned |
Gets an object returning data sent from the remote endpoint.
|
inlineexplicitnoexcept |
Check whether the connected_socket
is initialized.
connected_socket
socket_address is bound initialized false otherwise.output_stream< char > seastar::connected_socket::output | ( | size_t | buffer_size = 8192 | ) |
Gets the output stream.
Gets an object that sends data to the remote endpoint.
buffer_size | how much data to buffer |
void seastar::connected_socket::set_sockopt | ( | int | level, |
int | optname, | ||
const void * | data, | ||
size_t | len | ||
) |
Sets custom socket options. Based on setsockopt function. Linux users should refer to protocol-specific manuals to see available options, e.g. tcp(7), ip(7), etc.
void seastar::connected_socket::shutdown_input | ( | ) |
Disables input from the socket.
Current or future reads will immediately fail with an error. This is useful to abort operations on a socket that is not making progress due to a peer failure.
void seastar::connected_socket::shutdown_output | ( | ) |
Disables output to the socket.
Current or future writes that have not been successfully flushed will immediately fail with an error. This is useful to abort operations on a socket that is not making progress due to a peer failure.
future seastar::connected_socket::wait_input_shutdown | ( | ) |
Waits for the peer of this socket to disconnect
Note, that when the returned future is resolved for whatever reason socket may still be readable from, so the caller may want to wait for both events – this one and EOF from read.
Calling it several times per socket is not allowed (undefined behavior)