Message header type for sending and receiving low-level socket messages.
Message header type for sending and receiving ancillary data through socket.
Socket shutdown options.
read = SHUT_RDwrite = SHUT_WRread_write = SHUT_RDWR
Socket wrapper.
public sys::fildesusing protocol_type = intProtocol number type.
using duration = clock_type::durationDuration type.
using clock_type = std::chrono::system_clockClock type used in this class.
socket(fd_type sock)explicitprotectedConstruct the socket with bare file descriptor.
swap(socket & rhs) -> void
Swap with rhs.
receive_fds(fd_type * data, size_t n) -> void
Receive an array of n file descriptors pointed by data.
send_fds(const fd_type * data, size_t n) -> void
Send an array of n file descriptors pointed by data.
send(const void * buf, size_t n, int flags = 0) const -> ssize_t
Write n bytes from buffer pointed by buf to the socket.
std::errc::resource_unavailable_try_again and std::errc::operation_in_progress
receive(void * buf, size_t n, int flags = 0) const -> ssize_t
Read n bytes from the socket and store them in buffer pointed by buf.
std::errc::resource_unavailable_try_again and std::errc::operation_in_progress
receive(message_header & hdr, int flags) const -> UNISTDX_DEPRECATED ssize_treceive(message_header & hdr, message_flags flags = message_flags{}) const -> ssize_t
Receive low-level message hdr over the socket.
std::errc::resource_unavailable_try_again and std::errc::operation_in_progress
send(const message_header & hdr, int flags) const -> UNISTDX_DEPRECATED ssize_tsend(const message_header & hdr, message_flags flags = message_flags{}) const -> ssize_t
Send low-level message hdr through the socket.
std::errc::resource_unavailable_try_again and std::errc::operation_in_progress
peer_name() const -> socket_addressGet address of the client, connected to the socket.
name() const -> socket_addressGet bound socket address.
bind_addr() const -> socket_addressGet bound socket address. The same as name, but does not throw.
credentials() const -> user_credentialsGet UID, GID and PID of the process, that is connected to this socket (client).
set_user_timeout(duration d) -> voidSet TCP user timeout option (see RFC 5482).
set_keep_alive(int max_probes, duration idle_time, duration interval) -> void
Set keep-alive options.
unset(tcp_options name) -> voidSet boolean TCP option.
set(tcp_options name) -> voidSet boolean TCP option.
set(tcp_options name, const char * value, socket_length_type size) -> voidSet string TCP option.
template <class T> set(tcp_options name, T value) -> voidSet TCP option.
get(tcp_options name, char * value, socket_length_type & size) const -> voidGet string TCP option.
template <class T> get(tcp_options name) const -> TGet TCP option.
unset(options name) -> voidSet boolean socket option.
set(options name) -> voidSet boolean socket option.
template <class T> get(options name) const -> TGet socket option.
template <class T> set(options name, T value) -> voidSet socket option.
type() const -> socket_typeGet socket type.
setopt(option opt) -> UNISTDX_DEPRECATED voidSet boolean option.
shutdown(shutdown_flag how = shutdown_flag::read_write) -> void
Shutdown communication on the socket, but do not close it.
std::errc::not_connected and std::errc::not_supported
accept(socket & client_socket, socket_address & client_address) -> bool
Accept socket connection.
listen(int max_pending_connections = SOMAXCONN) -> voidListen on previously binded socket address.
connect(const socket_address_view & e) -> void
Connect to socket address e.
std::errc::operation_in_progress
bind(const socket_address_view & e) -> void
Bind on socket address e.
operator=(socket && rhs) -> socket &Move-assignment.
~socket()Close the socket.
socket(socket_address_family family, socket_type type = socket_type::stream, protocol_type proto = 0)explicit
Construct the socket with protocol family family, type type and protocol proto.
socket(const socket_address_view & bind_addr, const socket_address_view & conn_addr) -> UNISTDX_DEPRECATED
Construct the socket, bind on bind_addr and connect to a process listening on conn_addr.
socket(const socket_address_view & bind_addr) -> UNISTDX_DEPRECATEDexplicit
Construct the socket and bind on bind_addr and listen.
socket(fildes && rhs)explicitConstruct the socket from file descriptor rhs.
socket(socket && rhs)explicitMove-constructor.
operator=(const socket & rhs) -> socket &socket(const socket & rhs)socket()operator<<(std::ostream & out, const socket & rhs) -> std::ostream &Print socket file descriptor and status.
UNISTDX_FLAGS(shutdown_flag)