A thread-safe, move-only RAII wrapper for a native socket handle.
More...
#include <io/socket/socket_handle.hpp>
|
|
| socket_handle ()=default |
| | Initializes an invalid socket handle.
|
| |
|
| socket_handle (const socket_handle &other)=delete |
| |
|
auto | operator= (const socket_handle &other) -> socket_handle &=delete |
| |
| | socket_handle (socket_handle &&other) noexcept |
| | Move constructor.
|
| |
| auto | operator= (socket_handle &&other) noexcept -> socket_handle & |
| | Move assignment.
|
| |
| | socket_handle (native_socket_type handle) |
| | Constructs from a native socket handle.
|
| |
| | socket_handle (int domain, int type, int protocol) |
| | Constructs a new socket.
|
| |
|
| operator native_socket_type () const noexcept |
| | Gets the underlying native socket handle.
|
| |
|
| operator bool () const noexcept |
| | Checks if the socket handle is valid.
|
| |
|
auto | operator<=> (const socket_handle &other) const noexcept -> std::strong_ordering |
| | Compares two socket_handle objects.
|
| |
|
auto | operator== (const socket_handle &other) const noexcept -> bool |
| | Checks for equality between two socket_handle objects.
|
| |
|
auto | operator<=> (native_socket_type other) const noexcept -> std::strong_ordering |
| | Compares with a native socket handle.
|
| |
|
auto | operator== (native_socket_type other) const noexcept -> bool |
| | Checks for equality with a native socket handle.
|
| |
|
auto | set_error (int error) noexcept -> void |
| | Sets a socket error.
|
| |
|
auto | get_error () const noexcept -> std::error_code |
| | Gets the last socket error.
|
| |
|
| ~socket_handle () |
| | Closes the managed socket.
|
| |
A thread-safe, move-only RAII wrapper for a native socket handle.
Ensures unique ownership and automatic closing of a native socket handle.
◆ socket_handle() [1/3]
| io::socket::socket_handle::socket_handle |
( |
socket_handle && |
other | ) |
|
|
noexcept |
Move constructor.
- Parameters
-
◆ socket_handle() [2/3]
| io::socket::socket_handle::socket_handle |
( |
native_socket_type |
handle | ) |
|
|
explicit |
Constructs from a native socket handle.
- Parameters
-
| handle | The native socket handle to wrap. |
- Exceptions
-
| std::system_error | on invalid handle. |
◆ socket_handle() [3/3]
| io::socket::socket_handle::socket_handle |
( |
int |
domain, |
|
|
int |
type, |
|
|
int |
protocol |
|
) |
| |
|
explicit |
Constructs a new socket.
- Parameters
-
| domain | The communication domain (e.g., AF_INET). |
| type | The socket type (e.g., SOCK_STREAM). |
| protocol | The protocol (e.g., IPPROTO_TCP). |
- Exceptions
-
| std::system_error | on failure. |
◆ operator=()
Move assignment.
- Parameters
-
- Returns
- A reference to this
socket_handle.
The documentation for this class was generated from the following file: