12 #ifndef ROC_NETIO_SOCKET_OPS_H_
13 #define ROC_NETIO_SOCKET_OPS_H_
81 bool& completed_immediately);
#define ROC_ATTR_NODISCARD
Emit warning if function result is not checked.
AddrFamily
Address family.
ROC_ATTR_NODISCARD bool socket_close(SocketHandle sock)
Close socket.
int SocketHandle
Platform-specific socket handle.
ROC_ATTR_NODISCARD bool socket_create(address::AddrFamily family, SocketType type, SocketHandle &new_sock)
Create non-blocking socket.
SocketError
I/O error codes.
@ SockErr_Failure
Failure.
@ SockErr_WouldBlock
Operation can't be performed without blocking, try later.
@ SockErr_StreamEnd
End of stream, no more data.
ROC_ATTR_NODISCARD bool socket_shutdown(SocketHandle sock)
Gracefully shutdown connection.
ROC_ATTR_NODISCARD bool socket_listen(SocketHandle sock, size_t backlog)
Start listening for incoming connections.
ROC_ATTR_NODISCARD bool socket_end_connect(SocketHandle sock)
Finish connecting to remote peer.
ROC_ATTR_NODISCARD bool socket_accept(SocketHandle sock, SocketHandle &new_sock, address::SocketAddr &remote_address)
Accept incoming connection.
ROC_ATTR_NODISCARD ssize_t socket_try_send_to(SocketHandle sock, const void *buf, size_t bufsz, const address::SocketAddr &remote_address)
Try to send datagram via socket to given address, without blocking.
ROC_ATTR_NODISCARD bool socket_close_with_reset(SocketHandle sock)
Close socket and send reset to remote peer. Remote peer will get error when reading from connection.
const SocketHandle SocketInvalid
Invalid socket handle.
@ SocketType_Tcp
TCP socket.
@ SocketType_Udp
UDP socket.
ROC_ATTR_NODISCARD bool socket_begin_connect(SocketHandle sock, const address::SocketAddr &remote_address, bool &completed_immediately)
Initiate connecting to remote peer.
ROC_ATTR_NODISCARD bool socket_bind(SocketHandle sock, address::SocketAddr &local_address)
Bind socket to local address.
ROC_ATTR_NODISCARD ssize_t socket_try_recv(SocketHandle sock, void *buf, size_t bufsz)
Try to read bytes from socket without blocking.
ROC_ATTR_NODISCARD ssize_t socket_try_send(SocketHandle sock, const void *buf, size_t bufsz)
Try to write bytes to socket without blocking.
ROC_ATTR_NODISCARD bool socket_setup(SocketHandle sock, const SocketOpts &options)
Set socket options.
Commonly used types and functions.
bool disable_nagle
Disable Nagle's algorithm.