Network socket instance handle. More...
#include <socket.hpp>
Public Member Functions | |
| Socket (const Socket &)=delete | |
| Socket (Socket &&r) noexcept | |
| Socket & | operator= (Socket &)=delete |
| Socket & | operator= (Socket &&r) noexcept |
| Socket () noexcept | |
| Creates a new empty netwown socket. | |
| Socket (SocketType type, SocketFamily family, SocketAddressView localAddress, bool isBlocking=true, bool isOnlyIPv6=false, SslContextView sslContext=nullptr) | |
| Creates a new network socket instance. | |
| ~Socket () | |
| Destroys network socket instance. | |
| void | destroy () noexcept |
| Destroys network socket instance. | |
| Socket_T * | getInstance () const noexcept |
| Returns socket SSL context view instance. | |
| SocketType | getType () const noexcept |
| Returns socket communication protocol type. | |
| SocketFamily | getFamily () const noexcept |
| Returns socket internet protocol (IP) address family type. | |
| bool | isBlocking () const noexcept |
| Returns true if socket is in blocking mode. | |
| bool | isOnlyIPv6 () const noexcept |
| Returns true if IPv6 socket is not accepting IPv4 connections. | |
| void | getLocalAddress (SocketAddressView socketAddress) const |
| Gets local socket IP address. | |
| void | getRemoteAddress (SocketAddressView socketAddress) const |
| Gets remote socket IP address. | |
| SslContextView | getSslContext () const noexcept |
| Returns socket SSL context instance. | |
| void * | getHandle () const noexcept |
| Returns socket internal handle. | |
| bool | isNoDelay () const noexcept |
| Returns true if stream socket sends without caching. | |
| void | setNoDelay (bool value) noexcept |
| Sets socket no delay mode. | |
| bool | isListening () const noexcept |
| Returns true if socket is in the listening state. | |
| size_t | getQueueSize () const noexcept |
| Returns socket pending connections queue size. | |
| NetsResult | listen (size_t queueSize=256) noexcept |
| Puts socket in a listening state. | |
| NetsResult | accept (SocketView &accepted) noexcept |
| Accepts a new socket connection. | |
| NetsResult | acceptSsl () noexcept |
| Accepts socket SSL connection. | |
| NetsResult | connect (SocketAddressView remoteAddress) noexcept |
| Connects socket to the specified remote address. | |
| NetsResult | connectSsl (const char *hostname=nullptr) noexcept |
| Establishes socket SSL connection. | |
| NetsResult | shutdown (SocketShutdown shutdown=RECEIVE_SEND_SOCKET_SHUTDOWN) noexcept |
| Shutdowns part of the full-duplex connection. | |
| NetsResult | receive (void *receiveBuffer, size_t bufferSize, size_t &byteCount) noexcept |
| Receives pending socket data. | |
| NetsResult | send (const void *data, size_t byteCount) |
| Sends specified data to the remote socket. | |
| template<class T> | |
| NetsResult | send (const T &data) |
| Sends specified data to the remote socket. | |
| NetsResult | receiveFrom (SocketAddressView remoteAddress, void *receiveBuffer, size_t bufferSize, size_t &byteCount) noexcept |
| Receives pending data from the remote socket. | |
| NetsResult | sendTo (const void *data, size_t byteCount, SocketAddressView remoteAddress) noexcept |
| Sends specified data to the remote socket. | |
| template<class T> | |
| NetsResult | sendTo (const T &data, SocketAddressView remoteAddress) noexcept |
| Sends specified data to the remote socket. | |
| operator bool () const noexcept | |
| Returns true if socket view is not null. | |
Static Public Member Functions | |
| static void | disableSigpipe () noexcept |
| Disablea SIGPIPE signals on Linux for a current thread. | |
Protected Attributes | |
| Socket_T * | instance = nullptr |
Network socket instance handle.
See the socket.h
|
inline |
Creates a new network socket instance.
See the createSocket().
| type | socket communication protocol type |
| family | internet protocol address family |
| localAddress | socket local bind address instance |
| isBlocking | create socket in blocking mode |
| isOnlyIPv6 | create socket in IPv6 only mode |
| sslContext | socket SSL context instance or nullptr |
| Error | with a NetsResult string on failure. |
|
inline |
Destroys network socket instance.
See the destroySocket().
|
inlinenoexceptinherited |
Destroys network socket instance.
See the destroySocket().
|
inlinenoexceptinherited |
Returns socket communication protocol type.
See the getSocketType().
|
inlinenoexceptinherited |
Returns socket internet protocol (IP) address family type.
See the getSocketFamily().
|
inlinenoexceptinherited |
Returns true if socket is in blocking mode.
See the isSocketBlocking().
|
inlinenoexceptinherited |
Returns true if IPv6 socket is not accepting IPv4 connections.
See the isSocketOnlyIPv6().
|
inlineinherited |
Gets local socket IP address.
See the getSocketLocalAddress().
| Error | with a result string on failure. |
| [out] | socketAddress | socket IP address instance |
|
inlineinherited |
Gets remote socket IP address.
See the getSocketRemoteAddress().
| Error | with a result string on failure. |
| [out] | socketAddress | socket IP address instance |
|
inlinenoexceptinherited |
Returns socket SSL context instance.
See the getSocketSslContext().
|
inlinenoexceptinherited |
Returns socket internal handle.
See the getSocketHandle().
|
inlinenoexceptinherited |
Returns true if stream socket sends without caching.
See the isSocketNoDelay().
|
inlinenoexceptinherited |
Sets socket no delay mode.
Does stream socket sends without caching.
| value | no delay mode value |
|
inlinenoexceptinherited |
Returns true if socket is in the listening state.
See the isSocketListening().
|
inlinenoexceptinherited |
Returns socket pending connections queue size.
See the getSocketQueueSize().
|
inlinenoexceptinherited |
Puts socket in a listening state.
See the listenSocket().
| queueSize | pending connections queue size |
|
inlinenoexceptinherited |
Accepts a new socket connection.
See the acceptSocket().
| [out] | accepted | reference to the accepted socket |
|
inlinenoexceptinherited |
|
inlinenoexceptinherited |
Connects socket to the specified remote address.
See the connectSocket().
| remoteAddress | remote socket IP address instance |
|
inlinenoexceptinherited |
Establishes socket SSL connection.
See the connectSslSocket().
| [in] | hostname | remote socket SNI hostname or NULL |
|
inlinenoexceptinherited |
Shutdowns part of the full-duplex connection.
See the shutdownSocket().
| shutdown | socket connection shutdown mode |
|
inlinenoexceptinherited |
Receives pending socket data.
See the socketReceive().
| [out] | receiveBuffer | data receive buffer |
| bufferSize | data receive buffer size in bytes | |
| [out] | byteCount | reference to the received byte count |
|
inlineinherited |
Sends specified data to the remote socket.
See the socketSend().
| [in] | data | target data to send |
| byteCount | data byte count to send |
|
inlineinherited |
Sends specified data to the remote socket.
See the socketSend().
| T | type of the send data |
| [in] | data | target data to send |
|
inlinenoexceptinherited |
Receives pending data from the remote socket.
See the socketReceiveFrom().
| [out] | remoteAddress | remote socket IP address |
| [out] | receiveBuffer | data receive buffer |
| bufferSize | data receive buffer size in bytes | |
| [out] | byteCount | reference to the received byte count |
|
inlinenoexceptinherited |
Sends specified data to the remote socket.
See the socketSendTo().
| [in] | data | send data buffer |
| byteCount | data byte count to send | |
| remoteAddress | destination remote socket IP address |
|
inlinenoexceptinherited |
Sends specified data to the remote socket.
See the socketSendTo().
| T | type of the send data |
| [in] | data | target data to send |
| remoteAddress | destination remote socket IP address |