|
| TPollerDrivenSocket (T &poller, int domain, int type=SOCK_STREAM) |
| Constructs a TPollerDrivenSocket from a poller, domain, and socket type.
|
|
| TPollerDrivenSocket (const TAddress &addr, int fd, T &poller) |
| Constructs a TPollerDrivenSocket from an existing file descriptor.
|
|
| TPollerDrivenSocket (int fd, T &poller) |
|
auto | Accept () |
| Asynchronously accepts an incoming connection.
|
|
auto | Connect (const TAddress &addr, TTime deadline=TTime::max()) |
| Asynchronously connects to the specified address with an optional deadline.
|
|
auto | ReadSome (void *buf, size_t size) |
| Asynchronously reads data from the socket.
|
|
auto | WriteSome (const void *buf, size_t size) |
| Asynchronously writes data to the socket.
|
|
auto | WriteSomeYield (const void *buf, size_t size) |
| The WriteSomeYield and ReadSomeYield variants behave similarly to WriteSome/ReadSome.
|
|
auto | ReadSomeYield (void *buf, size_t size) |
| The WriteSomeYield and ReadSomeYield variants behave similarly to WriteSome/ReadSome.
|
|
| TSocket (TPollerBase &poller, int domain, int type=SOCK_STREAM) |
| Constructs a TSocket using the given poller, address family, and socket type.
|
|
| TSocket (const TAddress &addr, int fd, TPollerBase &poller) |
| Constructs a TSocket for an already-connected socket.
|
|
| TSocket (TSocket &&other) |
|
TSocket & | operator= (TSocket &&other) |
|
auto | Connect (const TAddress &addr, TTime deadline=TTime::max()) |
| Asynchronously connects to the specified address.
|
|
auto | Accept () |
| Asynchronously accepts an incoming connection.
|
|
void | Bind (const TAddress &addr) |
| Binds the socket to the specified local address.
|
|
void | Listen (int backlog=128) |
| Puts the socket in a listening state with an optional backlog (default is 128).
|
|
const std::optional< TAddress > & | RemoteAddr () const |
| Returns the remote address of the connected peer.
|
|
const std::optional< TAddress > & | LocalAddr () const |
| Returns the local address to which the socket is bound.
|
|
int | Fd () const |
| Returns the underlying socket descriptor.
|
|
auto | ReadSome (void *buf, size_t size) |
| Asynchronously reads data from the socket into the provided buffer.
|
|
auto | ReadSomeYield (void *buf, size_t size) |
| Forces a read operation on the next event loop iteration.
|
|
auto | WriteSome (const void *buf, size_t size) |
| Asynchronously writes data from the provided buffer to the socket.
|
|
auto | WriteSomeYield (const void *buf, size_t size) |
| Forces a write operation on the next event loop iteration.
|
|
auto | Monitor () |
| Monitors the socket for remote hang-up (closure).
|
|
void | Close () |
| Closes the socket.
|
|
template<typename T>
class NNet::TPollerDrivenSocket< T >
Socket type driven by the poller's implementation.
This class is used when socket operations (read, write, connect, etc.) are defined by the poller—in other words, when these operations depend on the underlying poller (e.g. for high-performance I/O using uring or IOCP).
Ordinary users should not worry about selecting the appropriate socket type. Instead, they should use the type defined by the poller, i.e. typename
TPoller::TSocket. Depending on the poller, this may resolve to either TSocket or TPollerDrivenSocket.
- Template Parameters
-
T | The poller type used by this socket. The poller must provide methods for asynchronous operations (such as Connect, Accept, Recv, and Send) and timer management. |