|
faio
faio 公共 C++ 接口参考
|
连接前可配置选项的 TCP 套接字。 更多...
Public 成员函数 | |
| auto | as_native_handle () const noexcept |
| 借用平台原生句柄。 | |
| auto | context () const noexcept |
| 获取对象所属 I/O 上下文。 | |
| expected< void > | bind (const SocketAddr &addressaddress) |
| 把套接字绑定到地址并按类型建立监听或数据报资源。 | |
| expected< TcpListener > | listen (int backlog=SOMAXCONN) && |
| 把已绑定的 TCP socket 转为监听器。 | |
| task< expected< TcpStream > > | connect (SocketAddr addressaddress) && |
| 连接目标地址或主机名。 | |
| auto | close () noexcept |
| 关闭句柄或通道端点。 | |
| expected< owned_native_socket > | into_native () |
| 导出原生资源并转移所有权。 | |
| expected< void > | set_nodelay (bool on) noexcept |
| 设置TCP_NODELAY,禁用或查询 Nagle 算法。 | |
| expected< bool > | nodelay () const noexcept |
| 读取TCP_NODELAY,禁用或查询 Nagle 算法。 | |
| expected< void > | set_keepalive (bool on) noexcept |
| 设置SO_KEEPALIVE 保活。 | |
| expected< bool > | keepalive () const noexcept |
| 读取SO_KEEPALIVE 保活。 | |
| expected< void > | set_recv_buffer_size (int size) noexcept |
| 设置接收缓冲区字节容量。 | |
| expected< void > | set_send_buffer_size (int size) noexcept |
| 设置发送缓冲区字节容量。 | |
| expected< std::size_t > | recv_buffer_size () const noexcept |
| 读取接收缓冲区字节容量。 | |
| expected< std::size_t > | send_buffer_size () const noexcept |
| 读取发送缓冲区字节容量。 | |
| expected< void > | set_linger (std::optional< std::chrono::seconds > duration) noexcept |
| 设置关闭时等待发送完成的 linger 时长。 | |
| expected< std::optional< std::chrono::seconds > > | linger () const noexcept |
| 读取关闭时等待发送完成的 linger 时长。 | |
| expected< void > | set_reuseaddr (bool on) noexcept |
| 设置本地地址复用。 | |
| expected< bool > | reuseaddr () const noexcept |
| 读取本地地址复用。 | |
| expected< void > | set_reuseport (bool on) noexcept |
| 设置端口复用(受平台支持限制)。 | |
| expected< bool > | reuseport () const noexcept |
| 读取端口复用(受平台支持限制)。 | |
| expected< void > | set_only_v6 (bool on) noexcept |
| 设置仅接受 IPv6。 | |
| expected< bool > | only_v6 () const noexcept |
| 读取仅接受 IPv6。 | |
| expected< void > | set_ttl (std::uint32_t value) noexcept |
| 设置IP 生存期/跳数。 | |
| expected< std::uint32_t > | ttl () const noexcept |
| 读取IP 生存期/跳数。 | |
| expected< std::optional< Error > > | take_error () const noexcept |
| 读取并清除套接字的待处理错误。 | |
| expected< void > | set_mark (std::uint32_t mark) noexcept |
| 设置Linux socket 标记。 | |
| expected< Addr > | local_addr () const noexcept |
| 查询本地绑定地址。 | |
静态 Public 成员函数 | |
| static expected< TcpSocket > | new_v4 (io::io_context context=io::io_context::current()) |
| 创建尚未连接的 IPv4 套接字。 | |
| static expected< TcpSocket > | new_v6 (io::io_context context=io::io_context::current()) |
| 创建尚未连接的 IPv6 套接字。 | |
| static expected< TcpSocket > | from_native (io::io_context context, owned_native_socket native) |
| 接管已拥有的原生资源。 | |
连接前可配置选项的 TCP 套接字。
|
noexcept |
借用平台原生句柄。
|
noexcept |
获取对象所属 I/O 上下文。
| expected< void > faio::net::TcpSocket::bind | ( | const SocketAddr & | address | ) |
把套接字绑定到地址并按类型建立监听或数据报资源。
| address | 目标 SocketAddr;对 send_to 是接收方,对 bind 是本地绑定地址。 |
| expected< TcpListener > faio::net::TcpSocket::listen | ( | int | backlog = SOMAXCONN | ) | && |
把已绑定的 TCP socket 转为监听器。
| backlog | 内核待接纳连接队列的长度提示,默认 SOMAXCONN。 默认值:SOMAXCONN。 |
| task< expected< TcpStream > > faio::net::TcpSocket::connect | ( | SocketAddr | address | ) | && |
连接目标地址或主机名。
| address | 目标 SocketAddr;对 send_to 是接收方,对 bind 是本地绑定地址。 |
|
noexcept |
关闭句柄或通道端点。
| expected< owned_native_socket > faio::net::TcpSocket::into_native | ( | ) |
导出原生资源并转移所有权。
|
static |
创建尚未连接的 IPv4 套接字。
| context | 目标 I/O 上下文;省略时使用当前上下文。资源创建后不会因协程迁移而改变归属。 默认值:io::io_context::current()。 |
|
static |
创建尚未连接的 IPv6 套接字。
| context | 目标 I/O 上下文;省略时使用当前上下文。资源创建后不会因协程迁移而改变归属。 默认值:io::io_context::current()。 |
|
static |
接管已拥有的原生资源。
| context | 目标 I/O 上下文;省略时使用当前上下文。资源创建后不会因协程迁移而改变归属。 |
| native | 需要转移所有权的原生资源拥有者。 |
|
noexcept |
设置TCP_NODELAY,禁用或查询 Nagle 算法。
| on | true 启用,false 关闭该 socket 选项。 |
|
noexcept |
读取TCP_NODELAY,禁用或查询 Nagle 算法。
|
noexcept |
设置SO_KEEPALIVE 保活。
| on | true 启用,false 关闭该 socket 选项。 |
|
noexcept |
读取SO_KEEPALIVE 保活。
|
noexcept |
设置接收缓冲区字节容量。
| size | 目标字节长度;set_size 不得超过 capacity,resize 可扩容。 |
|
noexcept |
设置发送缓冲区字节容量。
| size | 目标字节长度;set_size 不得超过 capacity,resize 可扩容。 |
|
noexcept |
读取接收缓冲区字节容量。
|
noexcept |
读取发送缓冲区字节容量。
|
noexcept |
设置关闭时等待发送完成的 linger 时长。
| duration | 等待时长或 socket linger 时长;时间单位由参数类型给出。 |
|
noexcept |
读取关闭时等待发送完成的 linger 时长。
|
noexcept |
设置本地地址复用。
| on | true 启用,false 关闭该 socket 选项。 |
|
noexcept |
读取本地地址复用。
|
noexcept |
设置端口复用(受平台支持限制)。
| on | true 启用,false 关闭该 socket 选项。 |
|
noexcept |
读取端口复用(受平台支持限制)。
|
noexcept |
设置仅接受 IPv6。
| on | true 启用,false 关闭该 socket 选项。 |
|
noexcept |
读取仅接受 IPv6。
|
noexcept |
设置IP 生存期/跳数。
| value | 要设置、编码或移动发送的值;具体类型见当前重载签名。 |
|
noexcept |
读取IP 生存期/跳数。
读取并清除套接字的待处理错误。
|
noexcept |
设置Linux socket 标记。
| mark | Linux socket 标记值。 |
|
noexcept |
查询本地绑定地址。