#include <icy/net/socket.h>Inherits:
SocketAdapterSubclassed by:TCPSocket,UDPSocket
Base socket implementation from which all sockets derive.
| Return | Name | Description |
|---|---|---|
std::any | opaque | Optional client data. |
std::any opaqueOptional client data.
The value is empty on initialization.
| Return | Name | Description |
|---|---|---|
Socket | Defaulted constructor. | |
Socket | Deleted constructor. | |
Socket | Deleted constructor. | |
void | connect | Connects to the given peer IP address. |
void | connect | Resolves and connects to the given host address. |
void | bind | Bind a local address to the socket. The address may be IPv4 or IPv6 (if supported). |
void | listen virtual inline | Listens the socket on the given address. |
bool | shutdown virtual inline | Sends the shutdown packet which should result is socket closure via callback. |
ssize_t | sendOwned | Sends an owned payload buffer to the connected peer. |
ssize_t | sendOwned | |
void | close | Closes the underlying socket. |
Address | address const | The locally bound address. |
Address | peerAddress const | The connected peer address. |
net::TransportType | transport const | The transport protocol: TCP, UDP or SSLTCP. |
void | setError | Sets the socket error. |
const icy::Error & | error const | Return the socket error if any. |
bool | closed const | Returns true if the native socket handle is closed. |
uv::Loop * | loop const | Returns the socket event loop. |
Socket() = defaultDefaulted constructor.
Socket(const Socket &) = deleteDeleted constructor.
Socket(Socket &&) = deleteDeleted constructor.
void connect(const Address & address)Connects to the given peer IP address.
Throws an exception if the address is malformed. Connection errors can be handled via the Error signal.
void connect(std::string_view host, uint16_t port)Resolves and connects to the given host address.
Throws an Exception if the host is malformed. Since the DNS callback is asynchronous implementations need to listen for the Error signal for handling connection errors.
void bind(const Address & address, unsigned flags)Bind a local address to the socket. The address may be IPv4 or IPv6 (if supported).
Throws an Exception on error.
virtual inline
virtual inline void listen(int backlog)Listens the socket on the given address.
Throws an Exception on error.
virtual inline
virtual inline bool shutdown()Sends the shutdown packet which should result is socket closure via callback.
ssize_t sendOwned(Buffer && buffer, int flags)Sends an owned payload buffer to the connected peer.
ssize_t sendOwned(Buffer && buffer, const Address & peerAddress, int flags)void close()Closes the underlying socket.
const
Address address() constThe locally bound address.
This function will not throw. A Wildcard 0.0.0.0:0 address is returned if the socket is closed or invalid.
const
Address peerAddress() constThe connected peer address.
This function will not throw. A Wildcard 0.0.0.0:0 address is returned if the socket is closed or invalid.
const
net::TransportType transport() constThe transport protocol: TCP, UDP or SSLTCP.
void setError(const icy::Error & err)Sets the socket error.
Setting the error will result in socket closure.
const
const icy::Error & error() constReturn the socket error if any.
const
bool closed() constReturns true if the native socket handle is closed.
const
uv::Loop * loop() constReturns the socket event loop.
| Return | Name | Description |
|---|---|---|
int | _af |
int _af {AF_UNSPEC}| Return | Name | Description |
|---|---|---|
void | init | Initializes the underlying socket context. |
void | reset | Resets the socket context for reuse. |
void init()Initializes the underlying socket context.
void reset()Resets the socket context for reuse.
std::shared_ptr< Socket > Ptr()std::vector< Ptr > Vec()