Functions for I/O Operations.
More...
|
| auto | io::accept (auto &&socket, std::span< std::byte > address={}) -> decltype(auto) |
| | Accepts an incoming connection on a listening socket.
|
| |
| auto | io::bind (auto &&socket, std::span< const std::byte > address) -> decltype(auto) |
| | Binds a socket to a local address.
|
| |
| auto | io::connect (auto &&socket, std::span< const std::byte > address) -> decltype(auto) |
| | Connects a socket to a remote address.
|
| |
| auto | io::fcntl (auto &&socket, int cmd, auto &&...args) -> decltype(auto) |
| | Performs a file control operation on a socket.
|
| |
| auto | io::getpeername (auto &&socket, std::span< std::byte > address) -> decltype(auto) |
| | Gets the peer address of a connected socket.
|
| |
| auto | io::getsockopt (auto &&socket, int level, int optname, std::span< std::byte > option) -> decltype(auto) |
| | Gets a socket option.
|
| |
| auto | io::getsockname (auto &&socket, std::span< std::byte > address) -> decltype(auto) |
| | Gets the local address of a socket.
|
| |
| auto | io::listen (auto &&socket, int backlog) -> decltype(auto) |
| | Sets a socket to listen for incoming connections.
|
| |
| auto | io::recvmsg (auto &&socket, auto &&msg, int flags) -> decltype(auto) |
| | Receives a message from a socket.
|
| |
| auto | io::sendmsg (auto &&socket, auto &&msg, int flags) -> decltype(auto) |
| | Sends a message on a socket.
|
| |
| auto | io::setsockopt (auto &&socket, int level, int optname, std::span< const std::byte > option) -> decltype(auto) |
| | Sets a socket option.
|
| |
| auto | io::shutdown (auto &&socket, int how) -> decltype(auto) |
| | Shuts down all or part of a connection on a socket.
|
| |
Functions for I/O Operations.
These functions are the main interface for performing socket operations. They dispatch to different implementations based on the arguments provided, allowing for both synchronous and asynchronous use.
◆ accept()
| auto io::accept |
( |
auto && |
socket, |
|
|
std::span< std::byte > |
address = {} |
|
) |
| -> decltype(auto)
|
|
inline |
Accepts an incoming connection on a listening socket.
- Parameters
-
| socket | A socket-like object. |
| address | A span to be populated with the peer's address. |
- Returns
- A
(socket, address) pair for synchronous operations, or a stdexec::sender for asynchronous operations.
◆ bind()
| auto io::bind |
( |
auto && |
socket, |
|
|
std::span< const std::byte > |
address |
|
) |
| -> decltype(auto)
|
|
inline |
Binds a socket to a local address.
- Parameters
-
| socket | A socket-like object. |
| address | The local address to bind to. |
- Returns
- 0 on success, -1 on error.
◆ connect()
| auto io::connect |
( |
auto && |
socket, |
|
|
std::span< const std::byte > |
address |
|
) |
| -> decltype(auto)
|
|
inline |
Connects a socket to a remote address.
- Parameters
-
| socket | A socket-like object. |
| address | The remote address to connect to. |
- Returns
- 0 on success, -1 on error for synchronous operations. A
stdexec::sender for asynchronous operations.
◆ fcntl()
| auto io::fcntl |
( |
auto && |
socket, |
|
|
int |
cmd, |
|
|
auto &&... |
args |
|
) |
| -> decltype(auto)
|
|
inline |
Performs a file control operation on a socket.
- Parameters
-
| socket | A socket-like object. |
| cmd | The command to perform. |
| args | Optional arguments for the command. |
- Returns
- The result of the underlying
fcntl call.
◆ getpeername()
| auto io::getpeername |
( |
auto && |
socket, |
|
|
std::span< std::byte > |
address |
|
) |
| -> decltype(auto)
|
|
inline |
Gets the peer address of a connected socket.
- Parameters
-
| socket | A socket-like object. |
| address | A span to be populated with the peer's address. |
- Returns
- A span containing the peer's address.
◆ getsockname()
| auto io::getsockname |
( |
auto && |
socket, |
|
|
std::span< std::byte > |
address |
|
) |
| -> decltype(auto)
|
|
inline |
Gets the local address of a socket.
- Parameters
-
| socket | A socket-like object. |
| address | A span to be populated with the local address. |
- Returns
- A span containing the local socket address.
◆ getsockopt()
| auto io::getsockopt |
( |
auto && |
socket, |
|
|
int |
level, |
|
|
int |
optname, |
|
|
std::span< std::byte > |
option |
|
) |
| -> decltype(auto)
|
|
inline |
Gets a socket option.
- Parameters
-
| socket | A socket-like object. |
| level | The protocol level of the option. |
| optname | The option name. |
| option | A span to be populated with the option value. |
- Returns
- A
(result, option) pair, where result is the return code of the underlying getsockopt call.
◆ listen()
| auto io::listen |
( |
auto && |
socket, |
|
|
int |
backlog |
|
) |
| -> decltype(auto)
|
|
inline |
Sets a socket to listen for incoming connections.
- Parameters
-
| socket | A socket-like object. |
| backlog | The maximum length of the pending connections queue. |
- Returns
- The result of the underlying
listen call.
◆ recvmsg()
| auto io::recvmsg |
( |
auto && |
socket, |
|
|
auto && |
msg, |
|
|
int |
flags |
|
) |
| -> decltype(auto)
|
|
inline |
Receives a message from a socket.
- Parameters
-
| socket | A socket-like object. |
| msg | A message object to receive data into. |
| flags | Flags to control the receive operation. |
- Returns
- The number of bytes received for synchronous operations. A
stdexec::sender for asynchronous operations.
◆ sendmsg()
| auto io::sendmsg |
( |
auto && |
socket, |
|
|
auto && |
msg, |
|
|
int |
flags |
|
) |
| -> decltype(auto)
|
|
inline |
Sends a message on a socket.
- Parameters
-
| socket | A socket-like object. |
| msg | The message object to send. |
| flags | Flags to control the send operation. |
- Returns
- The number of bytes sent for synchronous operations. A
stdexec::sender for asynchronous operations.
◆ setsockopt()
| auto io::setsockopt |
( |
auto && |
socket, |
|
|
int |
level, |
|
|
int |
optname, |
|
|
std::span< const std::byte > |
option |
|
) |
| -> decltype(auto)
|
|
inline |
Sets a socket option.
- Parameters
-
| socket | A socket-like object. |
| level | The protocol level of the option. |
| optname | The option name. |
| option | A span containing the option value. |
- Returns
- The result of the underlying
setsockopt call.
◆ shutdown()
| auto io::shutdown |
( |
auto && |
socket, |
|
|
int |
how |
|
) |
| -> decltype(auto)
|
|
inline |
Shuts down all or part of a connection on a socket.
- Parameters
-
| socket | A socket-like object. |
| how | A flag specifying which parts of the connection to shut down. |
- Returns
- The result of the underlying
shutdown call.