PLCnext API Documentation 24.6.0.58
All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Modules Pages
Public Types | Public Member Functions | Static Public Member Functions | List of all members
Arp::System::Commons::Net::TlsSocket2 Class Reference

Interface to realize TLS Connection over TCP More...

#include <TlsSocket2.hpp>

Inheritance diagram for Arp::System::Commons::Net::TlsSocket2:
Inheritance graph

Public Types

using Ptr = std::shared_ptr< TlsSocket2 >
 
using Certificate = Arp::System::Commons::Security::Certificate
 
using VerifyHandler = delegate< void(bool &, TlsVerificationError &, int, const Certificate *)>
 Used a for AddVerifyHandler Note: certificate is optional and can be nullptr, must be checked before use
 
using AlertHandler = delegate< void(TlsAlertType, TlsAlertLevel)>
 

Public Member Functions

 TlsSocket2 (SocketType type, SocketDomain domain, SocketBlockingMode blockingMode)
 
 TlsSocket2 (SocketType type, SocketDomain domain, SocketBlockingMode blockingMode, TlsOptions options)
 
 TlsSocket2 (const TlsSocket2 &arg)=delete
 
 TlsSocket2 (TlsSocket2 &&arg) noexcept
 
 TlsSocket2 (Socket::Ptr pSocket, TlsContextPtr pContext, bool isInitialized)
 
TlsSocket2operator= (const TlsSocket2 &arg)=delete
 
TlsSocket2operator= (TlsSocket2 &&arg) noexcept
 
SocketType GetSocketType (void)
 Returns the type of the socket. More...
 
SocketDomain GetSocketDomain (void)
 Returns the type of the socket. More...
 
bool IsBlocking (void)
 Checks if the socket is in blocking mode. More...
 
bool IsConnected (void)
 Checks if the socket is in blocking mode. More...
 
bool IsTlsConnected (void)
 Checks if a TLS connection is established with a remote peer. More...
 
IpAddress GetRemoteIpAddress (void)
 Checks if this socket is connected with a remote peer. More...
 
int GetRemotePort (void)
 If this socket is connected this method returns the port of the connection. More...
 
Ptr Accept (IpAddress &ip4address, int &port, SocketError &error)
 Accepts a pending connection request. More...
 
SocketError Bind (const IpAddress &ip4Address, int port)
 Binds the socket to a specific address and port combination. More...
 
SocketError Bind2 (const IpAddress &ip4Address, int &port)
 Binds the socket to a specific address and port combination. More...
 
SocketError Listen (size_t backlog)
 Marks this socket as a passive socket that accepts incoming connection requests. More...
 
SocketError Connect (const IpAddress &ip4Address, int port)
 Tries to connect with a remote socket. More...
 
SocketError Shutdown (void)
 Shuts down a full-duplex connection. More...
 
SocketError Shutdown (ShutdownMode mode)
 Shuts down a full-duplex connection. More...
 
SocketError Close (void)
 Closes the socket. This ends all communication on the socket. More...
 
int Send (const void *pBuffer, size_t length, SocketError &error)
 Transmit data over the socket that is in a connected state. More...
 
int Receive (void *pBuffer, size_t length, SocketError &error)
 Reads data from connected socket. More...
 
bool Select (SelectMode mode, Microseconds timeout, SocketError &error)
 Checks if an i/o operation can be performed without blocking the calling thread. More...
 
int Poll (PollMode mode, Milliseconds timeout, SocketError &error)
 Checks if an i/o operation can be processed without blocking. More...
 
SocketError SetSocketOption (SocketOptionName optionName, const void *optionValue, size_t optionLength)
 Sets a single option on the socket. More...
 
SocketError GetSocketOption (SocketOptionName optionName, void *optionValue, size_t *optionLength)
 Returns current value of queried socket option. More...
 
SocketError SetOptionReuseAddress (bool enabled)
 Enables/Disables the reuse-address option for this socket. More...
 
SocketError GetOptionReuseAddress (bool &enabled)
 Checks if reuse-address is enabled. More...
 
SocketError SetOptionKeepAlive (bool enabled)
 Enables/Disables the keep-alive option for this socket. More...
 
SocketError GetOptionKeepAlive (bool &enabled)
 Checks if keep-alive is enabled. More...
 
SocketError SetOptionBroadcast (bool enabled)
 Enables/Disables broadcast for this socket. More...
 
SocketError GetOptionBroadcast (bool &enabled)
 Checks if broadcast is enabled. More...
 
SocketError SetOptionNoDelay (bool enabled)
 Enables/Disables no-delay for this socket. More...
 
SocketError GetOptionNoDelay (bool &enabled)
 Checks if no-delay is enabled. More...
 
SocketError SetOptionLinger (bool enable, size_t timeout)
 Sets the amount of time a socket resides in TIME_WAIT state after active close. More...
 
SocketError GetOptionLinger (bool &enable, size_t &timeout)
 Returns the current linger options. For more information see Arp::System::Commons::Net::Socket::SetOptionLinger More...
 
SocketError SetOptionUserTimeout (size_t timeout_ms)
 Sets the retransmission timeout of a socket. This only works on Linux. More...
 
SocketError GetOptionUserTimeout (size_t &timeout_ms)
 Gets the retransmission timeout of a socket. This only works on Linux. For more information see Arp::System::Commons::Net::Socket::SetOptionUserTimeout More...
 
SocketError SetOptionKeepAliveIdleTime (int seconds)
 Sets the time that the socket needs to be idle for, before the Keep Alive mechanism can start if the KeepAlive SocketOption is set to true. More...
 
SocketError GetOptionKeepAliveIdleTime (int &seconds)
 Gets the time that the socket needs to be idle for, before the Keep Alive mechanism can start if the KeepAlive SocketOption is set to true. For more information see Arp::System::Commons::Net::Socket::SetOptionKeepAliveIdleTime More...
 
SocketError SetOptionKeepAliveProbeInterval (int seconds)
 Sets the interval time in between each Keep Alive probe, if the KeepAlive SocketOption is set to true. More...
 
SocketError GetOptionKeepAliveProbeInterval (int &seconds)
 Gets the interval time in between each Keep Alive probe, if the KeepAlive SocketOption is set to true. For more information see Arp::System::Commons::Net::Socket::SetOptionKeepAliveProbeInterval More...
 
SocketError SetOptionKeepAliveProbeCount (int probeCount)
 Sets the amount of probes to be sent, if the KeepAlive SocketOption is set to true. More...
 
SocketError GetOptionKeepAliveProbeCount (int &probeCount)
 Gets the amount of probes to be sent, if the KeepAlive SocketOption is set to true. For more information see Arp::System::Commons::Net::Socket::SetOptionKeepAliveProbeCount More...
 
SocketError SetOptionBlocking (bool enable)
 Enables/disables the blocking mode of this socket.. More...
 
SocketError InitClient (const String &trustStoreName, const String &identityStoreName, const String &hostName)
 
SocketError InitServer (const String &identityStoreName, const String &trustStoreName="")
 
void SetCipherList (const String &cipherList)
 
SocketError RenegotiateSession ()
 
SocketError UpdateSessionKeys (bool requestUpdate=true)
 
SocketError GetPeerCertificate (Certificate &certificate)
 
SteadyTimePoint GetLastRenegotionTime (void)
 Queries the last timepoint when a TLS renegotiation was performed More...
 
SteadyTimePoint GetLastKeyUpdateTime (void)
 Queries the last timepoint when a TLS session resumption (TLS 1.2) or key update (TLS 1.3) was performed More...
 
void AddVerifyHandler (const VerifyHandler &handler)
 Adds a handler which is called during certificate validation ot the peer certificate More...
 
void RemoveVerifyHandler (const VerifyHandler &handler)
 Removes a VerifyHandler again
 
void AddAlertReceivedHandler (const AlertHandler &handler)
 Adds a handler which is called when a TLS alert is received from the peer
 
void RemoveAlertReceivedHandler (const AlertHandler &handler)
 Removes a AlertReceived handler again
 
void AddAlertSendHandler (const AlertHandler &handler)
 Adds a handler which is called when a TLS alert is send to the peer
 
void RemoveAlertSendHandler (const AlertHandler &handler)
 Removes a AlertSend handler again
 
Impl & GetImpl (void)
 
const Impl & GetImpl (void) const
 

Static Public Member Functions

static String GetTlsVerificationErrorString (const TlsVerificationError &error)
 

Detailed Description

Interface to realize TLS Connection over TCP

This class can be use to provide an TLS Server or an TLS Client Socket Both Server and optional Client Certificates are supported

To provide the identity for a TLS Server or client a IdentityStore can be referenced by name remote certificates are checked against a TrustStore referenced by name

Member Function Documentation

◆ Accept()

Ptr Arp::System::Commons::Net::TlsSocket2::Accept ( IpAddress ip4address,
int &  port,
SocketError error 
)

Accepts a pending connection request.

Before a socket can accept connection requests, it must be Bind with an address and must be set to Listen state.

If no connection request is pending and the socket is in

  • blocking mode, the call blocks until a remote peer sends a connection request
  • non-blocking mode, the call returns a nullptr and error is set to SocketError::WouldBlock

Currently only ip v4 addresses are supported. The address must be encoded in a single 32 bit value. For an example how to encode the address see the example in the class description.

Parameters
ip4addressholds the 32 bit encoded ip v4 address of the connected peer socket.
portHolds the port number of the connected peer socket.
errorHolds error code in case the method returns nullptr.
Returns
Pointer to class instance representing accepted socket, nullptr otherwise.

◆ AddVerifyHandler()

void Arp::System::Commons::Net::TlsSocket2::AddVerifyHandler ( const VerifyHandler handler)

Adds a handler which is called during certificate validation ot the peer certificate

This handler can be used to:

  • implement futher checks for certificates (i.e. name checks, length checks)
  • override the checks to allow certificates normally rejected (i.e. just log CRL issues instead of reject)

◆ Bind()

SocketError Arp::System::Commons::Net::TlsSocket2::Bind ( const IpAddress ip4Address,
int  port 
)

Binds the socket to a specific address and port combination.

Currently only ip v4 addresses are supported. The address must be encoded in a single 32 bit value. For an example how to encode the address see the example in the class description.

To bind this socket to all local interfaces, 0 has to be assigned to parameter ip4Address.

Parameters
ip4AddressIP v4 based address to connect to.
portPort number to connect with.
Returns
See SocketError for more information on possible return values.

◆ Bind2()

SocketError Arp::System::Commons::Net::TlsSocket2::Bind2 ( const IpAddress ip4Address,
int &  port 
)

Binds the socket to a specific address and port combination.

bind2 returns the actual port used by this socket in the port parameter in contrast to bind i.e. use bind(ip, 0) to let the os choose the port to use, after the call port will contain the port choosed by the os.

Currently only ip v4 addresses are supported. The address must be encoded in a single 32 bit value. For an example how to encode the address see the example in the class description.

To bind this socket to all local interfaces, 0 has to be assigned to parameter ip4Address.

Parameters
ip4AddressIP v4 based address to connect to.
portPort number to connect with.
Returns
See SocketError for more information on possible return values.

◆ Close()

SocketError Arp::System::Commons::Net::TlsSocket2::Close ( void  )

Closes the socket. This ends all communication on the socket.

After Close() no further calls (i.e. a new connect()) on this socket are possible thus the socket instance must be destroyed.

Returns
See SocketError for more information on possible return values.

◆ Connect()

SocketError Arp::System::Commons::Net::TlsSocket2::Connect ( const IpAddress ip4Address,
int  port 
)

Tries to connect with a remote socket.

Currently only ip v4 addresses are supported. The address must be encoded in a single 32 bit value. For an example how to encode the address see the example in the class description.

Parameters
ip4AddressIP v4 based address to connect to.
portPort number to connect with.
Returns
See SocketError for more information on possible return values.

◆ GetLastKeyUpdateTime()

SteadyTimePoint Arp::System::Commons::Net::TlsSocket2::GetLastKeyUpdateTime ( void  )

Queries the last timepoint when a TLS session resumption (TLS 1.2) or key update (TLS 1.3) was performed

whenever a session resumption or key update is performed (initiated by this socket or the peer) for this TLS connection the timepoint is stored. with this method the last timepoint can be queried

Returns
The last session resumption or key update time in Milliseconds. Arp::SteadyClock::now is used to determine the timepoint If no connection is established yet SteadyTimePoint{} is returned

◆ GetLastRenegotionTime()

SteadyTimePoint Arp::System::Commons::Net::TlsSocket2::GetLastRenegotionTime ( void  )

Queries the last timepoint when a TLS renegotiation was performed

whenever a renogotiation is performed (initiated by this socket or the peer) for this TLS connection the timepoint is stored. with this method the last timepoint can be queried

Returns
The last renegotiation time in Milliseconds. Arp::SteadyClock::now is used to determine the timepoint If no connection is established yet SteadyTimePoint{} is returned

◆ GetOptionBroadcast()

SocketError Arp::System::Commons::Net::TlsSocket2::GetOptionBroadcast ( bool &  enabled)

Checks if broadcast is enabled.

See SetOptionBroadcast for more information.

Parameters
enabledContainer for current option state.
Returns
See SocketError for more information on possible return values.

◆ GetOptionKeepAlive()

SocketError Arp::System::Commons::Net::TlsSocket2::GetOptionKeepAlive ( bool &  enabled)

Checks if keep-alive is enabled.

See SetOptionKeepAlive for more information.

Parameters
enabledContainer for current option state.
Returns
See SocketError for more information on possible return values.

◆ GetOptionKeepAliveIdleTime()

SocketError Arp::System::Commons::Net::TlsSocket2::GetOptionKeepAliveIdleTime ( int &  seconds)

Gets the time that the socket needs to be idle for, before the Keep Alive mechanism can start if the KeepAlive SocketOption is set to true. For more information see Arp::System::Commons::Net::Socket::SetOptionKeepAliveIdleTime

Parameters
secondsGets the required Keep Alive socket idle time duration in seconds if Keep Alive is enabled.
Returns
See SocketError for more information on possible return values.

◆ GetOptionKeepAliveProbeCount()

SocketError Arp::System::Commons::Net::TlsSocket2::GetOptionKeepAliveProbeCount ( int &  probeCount)

Gets the amount of probes to be sent, if the KeepAlive SocketOption is set to true. For more information see Arp::System::Commons::Net::Socket::SetOptionKeepAliveProbeCount

Parameters
probeCountGets the amount of Keep Alive probes to be sent if Keep Alive is enabled.
Returns
See SocketError for more information on possible return values.

◆ GetOptionKeepAliveProbeInterval()

SocketError Arp::System::Commons::Net::TlsSocket2::GetOptionKeepAliveProbeInterval ( int &  seconds)

Gets the interval time in between each Keep Alive probe, if the KeepAlive SocketOption is set to true. For more information see Arp::System::Commons::Net::Socket::SetOptionKeepAliveProbeInterval

Parameters
secondsGets the interval in seconds in between Keep Alive probes if Keep Alive is enabled.
Returns
See SocketError for more information on possible return values.

◆ GetOptionLinger()

SocketError Arp::System::Commons::Net::TlsSocket2::GetOptionLinger ( bool &  enable,
size_t &  timeout 
)

Returns the current linger options. For more information see Arp::System::Commons::Net::Socket::SetOptionLinger

Parameters
enableTrue if linger option is active, otherwise false.
timeoutHolds current timeout value in seconds if linger is activated on this socket.
Returns
See SocketError for more information on possible return values.

◆ GetOptionNoDelay()

SocketError Arp::System::Commons::Net::TlsSocket2::GetOptionNoDelay ( bool &  enabled)

Checks if no-delay is enabled.

See SetOptionNoDelay for more information.

Parameters
enabledContainer for current option state.
Returns
See SocketError for more information on possible return values.

◆ GetOptionReuseAddress()

SocketError Arp::System::Commons::Net::TlsSocket2::GetOptionReuseAddress ( bool &  enabled)

Checks if reuse-address is enabled.

See SetOptionReuseAddress for more information

Parameters
enabledContainer for current option state.
Returns
See SocketError for more information on possible return values.

◆ GetOptionUserTimeout()

SocketError Arp::System::Commons::Net::TlsSocket2::GetOptionUserTimeout ( size_t &  timeout_ms)

Gets the retransmission timeout of a socket. This only works on Linux. For more information see Arp::System::Commons::Net::Socket::SetOptionUserTimeout

Parameters
timeout_msHolds the current retransmission timeout value in milliseconds if it has been set on this socket.
Returns
See SocketError for more information on possible return values.

◆ GetRemoteIpAddress()

IpAddress Arp::System::Commons::Net::TlsSocket2::GetRemoteIpAddress ( void  )

Checks if this socket is connected with a remote peer.

Returns
True if this socket is connected, otherwise false is returned.

◆ GetRemotePort()

int Arp::System::Commons::Net::TlsSocket2::GetRemotePort ( void  )

If this socket is connected this method returns the port of the connection.

The port number is returned in host byte order, not in network byte order.

Returns
The port of the connection if this port is connected, otherwise 0 is returned.

◆ GetSocketDomain()

SocketDomain Arp::System::Commons::Net::TlsSocket2::GetSocketDomain ( void  )

Returns the type of the socket.

Returns
Type of socket.

◆ GetSocketOption()

SocketError Arp::System::Commons::Net::TlsSocket2::GetSocketOption ( SocketOptionName  optionName,
void *  optionValue,
size_t *  optionLength 
)

Returns current value of queried socket option.

Parameters
optionNameName of option where current value is queried.
optionValuePointer to buffer where current socket option value is to be stored.
optionLengthValue-Result argument. Must be initialized to byte size of buffer pointed to by optionValue. Holds amount of bytes set in buffer optionValue after call returned.
Returns
See SocketError for more information on possible return values.

◆ GetSocketType()

SocketType Arp::System::Commons::Net::TlsSocket2::GetSocketType ( void  )

Returns the type of the socket.

Returns
Type of socket.

◆ InitClient()

SocketError Arp::System::Commons::Net::TlsSocket2::InitClient ( const String trustStoreName,
const String identityStoreName,
const String hostName 
)

summary>Initializes this TLS socket in server mode. This method must be called before accepting connections with Accept

param name="identityStoreName"> name of the IdentityStore to use for the server identity (certificcate) the referenced identity store is used as the server certificate /param>

param name="trustStoreName"> optional name of the truststore which should be used to verify the client certificate if the client certificate should not be checked the paramter can be omitted or set to "" /param>

◆ InitServer()

SocketError Arp::System::Commons::Net::TlsSocket2::InitServer ( const String identityStoreName,
const String trustStoreName = "" 
)

summary>Sets the supported ciphers of this socket which are used during connection negotiation

also see: https://www.openssl.org/docs/man1.0.2/apps/ciphers.html if this method is called with an empty String, SSL_CTX_set_cipher_list is not called for this TLS connection and the OpenSSL default is used.

param name="cipherList"> The String of ciphers which should be supported. Format of the string as specified by OpenSSL. /param>

◆ IsBlocking()

bool Arp::System::Commons::Net::TlsSocket2::IsBlocking ( void  )

Checks if the socket is in blocking mode.

Returns
True if socket is in blocking mode, otherwise false is returned.

◆ IsConnected()

bool Arp::System::Commons::Net::TlsSocket2::IsConnected ( void  )

Checks if the socket is in blocking mode.

Returns
True if socket is in blocking mode, otherwise false is returned.

◆ IsTlsConnected()

bool Arp::System::Commons::Net::TlsSocket2::IsTlsConnected ( void  )

Checks if a TLS connection is established with a remote peer.

Returns
True if this TLS is established, otherwise false is returned.

◆ Listen()

SocketError Arp::System::Commons::Net::TlsSocket2::Listen ( size_t  backlog)

Marks this socket as a passive socket that accepts incoming connection requests.

A socket in listening state features an internal queue where incoming connection requests are stored until they are processed by an Accept invocation. The maximal capacity of this queue is determined by the parameter backlog. If a connection request arrives while the queue is filled, the client may receive an error telling that the connection is refused or, if the utilized protocol allows retransmissions, the request may be ignored so that a consecutive reattempt to connnect may succeed.

Parameters
backlogDefines the maximum number of pending connection requests.
Returns
See SocketError for more information on possible return values.

◆ Poll()

int Arp::System::Commons::Net::TlsSocket2::Poll ( PollMode  mode,
Milliseconds  timeout,
SocketError error 
)

Checks if an i/o operation can be processed without blocking.

Parameters
modeSpecifies the i/o operation to be checked.
timeoutSpecifies the timeout to wait for the socket to get ready for the i/o operation. If set to zero, the call will return immediately. Milliseconds(-1) determines infinite.
errorThe resulting socket error, if any error occur.
Returns
1 if the specified i/o operation might be processed without blocking. 0 if this operation timed out. -1 if any error occurs. Check the error to get more infos about the error. If the socket was closed local or remote, the error is <cref name="SocketError::ConnectionReset" >.

◆ Receive()

int Arp::System::Commons::Net::TlsSocket2::Receive ( void *  pBuffer,
size_t  length,
SocketError error 
)

Reads data from connected socket.

Parameters
pBufferPointer to buffer where read data can be stored.
lengthCapacity in bytes of buffer pBuffer.
errorContainer variable holding error code after call returned.
Returns
Amount of bytes read from socket, -1 in case of failure.

◆ RenegotiateSession()

SocketError Arp::System::Commons::Net::TlsSocket2::RenegotiateSession ( )

summary>Update the keys for the current established TLS session

For TLS 1.2 this will be done with a SessionResumption (which might also involve a Renegotiation if the session can not be resumed) The requestUpdate parameter is ignored for TLS1.2

For TLS 1.3 a KeyUdpate will be done, if requestUpdate is true the peer will be ask to also update the keys if requestUpdate is false the keys will be updated and the peer is imformed about the update param name="requestUpdate"> Wether to request the update from the peer (only for TLS1.3), ignored for TLS 1.2 /param>

Returns
See SocketError for more information on possible return values. SocketError::None if update was successful, SocketError::Any in case of an error, SocketError::OperationNotSupported when a TLS connection is not established

◆ Select()

bool Arp::System::Commons::Net::TlsSocket2::Select ( SelectMode  mode,
Microseconds  timeout,
SocketError error 
)

Checks if an i/o operation can be performed without blocking the calling thread.

Parameters
modeDetermines the i/o operation to be checked.
timeoutSpecifies the time to wait for the socket to be ready for the i/o operation. If set to zero, the call will return immediately.
errorContainer variable holding error code after call returned.
Returns
True if the specified i/o operation can be performed without blocking, otherwise false is returned.

◆ Send()

int Arp::System::Commons::Net::TlsSocket2::Send ( const void *  pBuffer,
size_t  length,
SocketError error 
)

Transmit data over the socket that is in a connected state.

Parameters
pBufferPointer to buffer containing serialized data to be send.
lengthAmount of bytes to be send.
errorContainer variable holding error code after call returned.
Returns
Amount of transmitted bytes, -1 in case of failure.

◆ SetCipherList()

void Arp::System::Commons::Net::TlsSocket2::SetCipherList ( const String cipherList)

summary>Triggeres a complete renegotion of the esstablished TLS session

Can be only used for TLS 1.2 connections.

Returns
See SocketError for more information on possible return values. SocketError::None if update was successful, SocketError::Any in case of an error, SocketError::ProtoType if called for TLS 1.3 connections, SocketError::OperationNotSupported when a TLS connection is not established

◆ SetOptionBlocking()

SocketError Arp::System::Commons::Net::TlsSocket2::SetOptionBlocking ( bool  enable)

Enables/disables the blocking mode of this socket..

Parameters
enabletrue if the blocking mode shall be enabled, otherwise false.
Returns
SocketError for more information on possible return values.

summary>Initializes this TLS socket in client mode. This method must be called before connecting to a server

param name="trustStoreName"> name of the TrustStore to use to verify the remote server certificate /param>

param name="identityStoreName"> name of the IdentityStore to use for the client identity the references store is used to authenticate against the server if client authentication should not be used the identityStoreName can be set to "" /param>

param name="hostName"> the hostname (or ip-address) which should be used while verifying the server certificate. the hostname if compared against the Subject entry of the server certificate if the hostname should not be checked the hostName can be set to "" /param>

◆ SetOptionBroadcast()

SocketError Arp::System::Commons::Net::TlsSocket2::SetOptionBroadcast ( bool  enabled)

Enables/Disables broadcast for this socket.

This option is only valid for datagram sockets and can be used to enable the sending of packets to broadcast addresses.

Parameters
enabledSet to tro true activate option, otherwise set to false.
Returns
See SocketError for more information on possible return values.

◆ SetOptionKeepAlive()

SocketError Arp::System::Commons::Net::TlsSocket2::SetOptionKeepAlive ( bool  enabled)

Enables/Disables the keep-alive option for this socket.

Enables the sending of keep-alive probes to remote peers to check if a connection is still up if no data was transmitted for a while.

This option is only valid for connection-based sockets.

Parameters
enabledSet to true to activate option, otherwise set to false.
Returns
See SocketError for more information on possible return values.

◆ SetOptionKeepAliveIdleTime()

SocketError Arp::System::Commons::Net::TlsSocket2::SetOptionKeepAliveIdleTime ( int  seconds)

Sets the time that the socket needs to be idle for, before the Keep Alive mechanism can start if the KeepAlive SocketOption is set to true.

Parameters
secondsSets the required Keep Alive socket idle time duration in seconds if Keep Alive is set to true.
Returns
See SocketError for more information on possible return values.

◆ SetOptionKeepAliveProbeCount()

SocketError Arp::System::Commons::Net::TlsSocket2::SetOptionKeepAliveProbeCount ( int  probeCount)

Sets the amount of probes to be sent, if the KeepAlive SocketOption is set to true.

Parameters
probeCountSets the amount of Keep Alive probes to be sent if Keep Alive is enabled.
Returns
See SocketError for more information on possible return values.

◆ SetOptionKeepAliveProbeInterval()

SocketError Arp::System::Commons::Net::TlsSocket2::SetOptionKeepAliveProbeInterval ( int  seconds)

Sets the interval time in between each Keep Alive probe, if the KeepAlive SocketOption is set to true.

Parameters
secondsSets the interval in seconds in between Keep Alive probes if Keep Alive is enabled.
Returns
See SocketError for more information on possible return values.

◆ SetOptionLinger()

SocketError Arp::System::Commons::Net::TlsSocket2::SetOptionLinger ( bool  enable,
size_t  timeout 
)

Sets the amount of time a socket resides in TIME_WAIT state after active close.

The port of a connection that is activly closed, i.e. first calls Arp::System::Commons::Net::Socket::Close will reside in a state called TIME_WAIT for a specific amount of time. This prevents subsequently delivered packages to be considered to belong to a potential new established connection using the same port.

The time a port is in TIME_WAIT state can be adjusted using this method. A smaller timeout can be of interest if the system has to manage a lot of connections that only are active for a small amount of time. In this case a small timeout will prevent a lot of socket residing in TIME_WAIT and are therefore unavailable for creation of new connections.

Parameters
enableSet to true to activate new linger timeout, false otherwise.
timeoutThe new linger timeout in seconds.
Returns
See SocketError for more information on possible return values.

◆ SetOptionNoDelay()

SocketError Arp::System::Commons::Net::TlsSocket2::SetOptionNoDelay ( bool  enabled)

Enables/Disables no-delay for this socket.

If this option is enabled packets are not buffered by the TCP stack stack to optimize the network usage by only sending sufficiently large amount of data. Instead even small packets are send immediately over the network.

Parameters
enabledSet to tro true activate option, otherwise set to false.
Returns
See SocketError for more information on possible return values.

◆ SetOptionReuseAddress()

SocketError Arp::System::Commons::Net::TlsSocket2::SetOptionReuseAddress ( bool  enabled)

Enables/Disables the reuse-address option for this socket.

Activating this option changes the validation process for socket bindings. If the option is disabled and one port is for example bound to 0.0.0.0:21 (any local address and port 21) another port can not be bound to 192.168.0.4:21 because the wildcard IP address 0.0.0.0 conflicts with the other address. If the option is enabled, bounding the second socket will succeed.

Parameters
enabledSet to true to enable the option, otherwise set to false.
Returns
See SocketError for more information on possible return values.

◆ SetOptionUserTimeout()

SocketError Arp::System::Commons::Net::TlsSocket2::SetOptionUserTimeout ( size_t  timeout_ms)

Sets the retransmission timeout of a socket. This only works on Linux.

By default, in the case of a retransmission, the system will use the global "tcp_retries2" value in a backoff algorithm (Doubles each try) in order to try and resend its data. Generally this can last for around 13-30 minutes, depending on the "tcl_retries2" value.

During this time, the socket will not be able to enter an idle state, therefore blocking the KeepAlive mechanism until after the retransmission phase has completed, even if the connection is no longer valid.

This SocketOption enables a timeout that will override the maximum length the rentransmission phase can last, on order to be able to utilize KeepAlive to detect a broken connection before the long retransmission phase ends.

It is generally adviced that the timeout should be set slightly lower than the total time the KeepAlive process takes, to ensure that both retransmission occurs and KeepAlive probes are able to be sent.

Parameters
timeout_msSets a new retransmission timeout in milliseconds.
Returns
See SocketError for more information on possible return values.

◆ SetSocketOption()

SocketError Arp::System::Commons::Net::TlsSocket2::SetSocketOption ( SocketOptionName  optionName,
const void *  optionValue,
size_t  optionLength 
)

Sets a single option on the socket.

Parameters
optionNameName of option ot be set.
optionValuePointer to additional data for socket option.
optionLengthByte size of buffer pointed to by optionValue.
Returns
See SocketError for more information on possible return values.

◆ Shutdown() [1/2]

SocketError Arp::System::Commons::Net::TlsSocket2::Shutdown ( ShutdownMode  mode)

Shuts down a full-duplex connection.

After the shutdown has been called, further reception and transmission on the socket is disallowed.

Parameters
modeSpecifies if read or write operations should be shutdown.
Returns
See SocketError for more information on possible return values.

◆ Shutdown() [2/2]

SocketError Arp::System::Commons::Net::TlsSocket2::Shutdown ( void  )

Shuts down a full-duplex connection.

After the shutdown has been called, further reception and transmission on the socket is disallowed.

Returns
See SocketError for more information on possible return values.

◆ UpdateSessionKeys()

SocketError Arp::System::Commons::Net::TlsSocket2::UpdateSessionKeys ( bool  requestUpdate = true)

summary>Retrieves the certificate of the TLS peer

Retrieves the peer certificate of this socket. This is the client certificate a client used for TLS client authentication in case of a server socket This is the certificate of the server the client is connected to in case of a client socket

param name="certificate"> reference to a Certificate object which will be filled in case the peer certificate can be received /param>

Returns
See SocketError for more information on possible return values. SocketError::None if update was successful, SocketError::Any in case of an error (no peer certificate avaliable i.e. a client connected without client authentication), SocketError::OperationNotSupported when a TLS connection is not established

The documentation for this class was generated from the following file: