VR-Link API Documentation for DIS
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
List of all members | Public Member Functions | Protected Member Functions | Protected Attributes | Static Protected Attributes
DtInetTlsSocket Class Reference
+ Inheritance diagram for DtInetTlsSocket:
+ Collaboration diagram for DtInetTlsSocket:

Public Member Functions

 DtInetTlsSocket ()
 
 DtInetTlsSocket (DtU16 localPort, DtInetDevice *hostIf=nullptr, DtInetUtils::DtInetAddrFamily family=DtInetUtils::DtInetAddrFamily_IPv4, DtU32 flags=DtSockOptNoDelay, bool immediateOpen=true)
 Server Socket Constructor. More...
 
 DtInetTlsSocket (const DtInetEndpoint &dest, DtU16 localPort=0, DtInetDevice *hostIf=nullptr, DtU32 flags=DtDefaultSockOpts, bool immediateOpen=true)
 Interactive Socket Constructors. More...
 
virtual ~DtInetTlsSocket ()
 
virtual bool handshakeDestination ()
 Perform SSL handshake after TCP connection is established. More...
 
virtual bool setSocket (const DtInetEndpoint &dest, DtU16 localPort=0, DtInetDevice *hostIf=nullptr, DtU32 flags=DtDefaultSockOpts) override
 Use TCP base for destination, binding, and options. More...
 
virtual bool setDestination (const DtInetEndpoint &addr) override
 Use TCP base for destination, binding, and options. More...
 
virtual bool openSocket () override
 Use TCP base for destination, binding, and options. More...
 
virtual bool closeSocket () override
 Use TCP base for destination, binding, and options. More...
 
virtual bool listenForConnections () override
 Use TCP base for destination, binding, and options. More...
 
virtual bool acceptConnection (DtInetTcpSocket *peer, DtU32 flags=DtDefaultSockOpts) override
 Use TCP base for destination, binding, and options. More...
 
virtual int send (caddr_t packet, size_t size, DtU32 flags=0) override
 Use TCP base for destination, binding, and options. More...
 
virtual int sendTo (caddr_t packet, size_t size, DtInetEndpoint &dest, DtU32 flags=0) override
 Use TCP base for destination, binding, and options. More...
 
virtual int sendChain (DtInetBufferChain &packets, DtU32 flags=0) override
 Use TCP base for destination, binding, and options. More...
 
virtual int sendChainTo (DtInetBufferChain &packets, DtInetEndpoint &dest, DtU32 flags=0) override
 Use TCP base for destination, binding, and options. More...
 
virtual DtInetSockRcvStatus recv (caddr_t buff, size_t buffSize, DtU32 flags=0) override
 Use TCP base for destination, binding, and options. More...
 
virtual DtInetSockRcvStatus recvToChain (DtInetBufferChain &packets, DtU32 flags=0) override
 Use TCP base for destination, binding, and options. More...
 
virtual DtInetSockRcvStatus recvFrom (caddr_t buff, size_t buffSize, DtInetEndpoint &src, DtU32 flags=0) override
 Use TCP base for destination, binding, and options. More...
 
virtual DtInetSockRcvStatus recvToChainFrom (DtInetBufferChain &packets, DtInetEndpoint &src, DtU32 flags=0) override
 Use TCP base for destination, binding, and options. More...
 
virtual unsigned descriptor () const override
 Use TCP base for destination, binding, and options. More...
 
- Public Member Functions inherited from DtInetTcpSocket
 DtInetTcpSocket (DtInetProtocol protocolToUse=DtInetProtocol_TCP)
 Default Constructor. More...
 
 DtInetTcpSocket (DtU16 localPort, DtInetDevice *hostIf=nullptr, DtInetUtils::DtInetAddrFamily family=DtInetUtils::DtInetAddrFamily_IPv4, DtU32 flags=DtSockOptNoDelay, bool immediateOpen=true, DtInetProtocol protocolToUse=DtInetProtocol_TCP)
 Server Socket Constructor. More...
 
 DtInetTcpSocket (const DtInetEndpoint &dest, DtU16 localPort=0, DtInetDevice *hostIf=nullptr, DtU32 flags=DtDefaultSockOpts, bool immediateOpen=true)
 Interactive Socket Constructors. More...
 
virtual ~DtInetTcpSocket ()
 Destructor. More...
 
virtual bool bindToDevice (const DtInetDevice *hostIf=nullptr) override
 Set the network interface device the socket will attempt to bind to on the local host. More...
 
virtual bool connectToDestination () override
 Initiate a connection to the destination endpoint. More...
 
virtual bool isOk () override
 Deprecated. More...
 
virtual bool setNonBlockingOption (bool onOrOff)
 
virtual bool setReuseAddressOption (bool onOrOff)
 
virtual bool setSendBufferSize (DtU32 size)
 
virtual bool setReceiveBufferSize (DtU32 size)
 
virtual bool setDoNotRouteOption (bool onOrOff)
 
virtual bool setSendLowWatermark (DtU32 size)
 
virtual bool setReceiveLowWatermark (DtU32 size)
 
virtual bool setTcpNoDelayOption (bool onOrOff)
 
virtual bool setTcpLingerOption (DtU16 timeout)
 
virtual bool setConnAbortedOption (bool onOrOff)
 
virtual bool setTcpKeepAliveOption (bool onOrOff)
 
virtual DtU32 getSendBufferSize ()
 
virtual DtU32 getReceiveBufferSize ()
 
virtual DtU32 getBytesAvailable ()
 
virtual bool getReuseAddressOption ()
 
virtual bool getDoNotRouteOption ()
 
virtual DtU32 getSendLowWatermark ()
 
virtual DtU32 getReceiveLowWatermark ()
 
virtual bool getTcpLingerOption (DtU16 &timeout)
 
virtual bool getConnAbortedOption ()
 
virtual bool getTcpKeepAliveOption ()
 
- Public Member Functions inherited from DtInetSocket
 DtInetSocket ()
 Default Constructor. More...
 
virtual ~DtInetSocket ()
 Destructor. More...
 
virtual const DtInetEndpoint & destination () const
 
virtual const DtInetEndpoint & localEndpoint () const
 Get the local endpoint for the socket. More...
 
virtual bool setLocalPort (DtU16 port)
 Set / get the local port number of the socket. More...
 
virtual DtU16 localPort () const
 
virtual const DtInetDevice * hostIf () const
 Get the host network interface device the socket is bound to. More...
 
virtual DtInetSockState state ()
 Return the present state of the socket. More...
 
virtual DtU32 protocol () const
 Get the protocol (DtInetProtocol_TCP or DtInetProtocol_UDP) More...
 
virtual
DtInetUtils::DtInetAddrFamily 
family () const
 Get the address family, IPv4 or IPv6. More...
 
virtual DtU32 flags ()
 Get the flags for this socket. More...
 
virtual DtU64 totalBytesSent () const
 Get traffic statistics. More...
 
virtual DtU64 totalPacketsSent () const
 
virtual DtU64 totalBytesReceived () const
 
virtual DtU64 totalPacketsReceived () const
 
virtual void clearStats ()
 Reset all statistics. More...
 
virtual bool addProcessingCallback (DtInetSockProcessingType kind, DtInetSocketProcessingCallback cb, void *usr, int callSequence=-1)
 Add / remove pre- and post- processing callbacks. More...
 
virtual bool removeProcessingCallback (DtInetSockProcessingType kind, DtInetSocketProcessingCallback cb)
 
virtual DtTime receiveTime ()
 
virtual bool isNonBlocking () const
 
virtual bool isNoDelay () const
 
virtual bool isIPv4 () const
 Return true if the socket matches the queried family or protocol. More...
 
virtual bool isIPv6 () const
 Return true if the socket matches the queried family or protocol. More...
 
virtual bool isTcp () const
 Return true if the socket matches the queried family or protocol. More...
 
virtual bool isTls () const
 Return true if the socket matches the queried family or protocol. More...
 
virtual bool isUdp () const
 Return true if the socket matches the queried family or protocol. More...
 
virtual int getLastError () const
 Return code or string describing last error. More...
 
virtual const DtString & getLastErrorString () const
 Return code or string describing last error. More...
 
virtual bool isErrorWouldBlockOrTryAgain () const
 Return code or string describing last error. More...
 
virtual void clearError ()
 Return code or string describing last error. More...
 
virtual int getTerminationCode () const
 Return code or string describing termination cause. More...
 
virtual const DtString & getTerminationString () const
 Return code or string describing termination cause. More...
 

Static Public Member Functions

static void setServerCRT (const DtString &crt)
 
static const DtString & serverCRT ()
 
static void setServerKey (const DtString &key)
 
static const DtString & serverKey ()
 
static void setClientCRT (const DtString &crt)
 
static const DtString & clientCRT ()
 
static void setClientKey (const DtString &key)
 
static const DtString & clientKey ()
 
static void setCaCRT (const DtString &crt)
 
static const DtString & caCRT ()
 
static void setCertificateFolder (const DtString &folder)
 
static const DtString & certificateFolder ()
 
static void setClientCertRequired (bool required)
 
static bool clientCertRequired ()
 

Protected Member Functions

virtual bool initSslForListening ()
 Initialize SSL context for server/listening sockets. Returns true on success. More...
 
virtual bool initClientSslContext ()
 
virtual bool buildCertificateFilePath (DtFilename &certFilename)
 Build the file path for the certificate file, prepending the certificate folder if the file name is relative. More...
 
- Protected Member Functions inherited from DtInetTcpSocket
virtual bool initAcceptedConnection (const DtInetEndpoint &localEndpoint, DtU32 flags=DtDefaultSockOpts)
 Accepted Connection Initializer. More...
 
virtual bool openAcceptedConnection (const DtInetEndpoint &peer)
 Accepted Connection finalizer. More...
 
virtual bool openSocket (DtInetProtocol protocolToUse)
 Used by this class and derivations to open socket with specified protocol (e.g., TCP or TLS) More...
 
virtual void * tcpSocket ()
 Return the underlying socket object. Must be cast to appropriate type before using. More...
 
virtual void * tcpServerSocket ()
 
bool isServerSock () const
 Return true if the socket is a listening (aka 'server') socket. More...
 
- Protected Member Functions inherited from DtInetSocket
virtual bool findAndRemoveCallback (DtInetSockCallbackList &cbList, DtInetSocketProcessingCallback cb)
 

Protected Attributes

bool myStreamIsOpen
 Track whether the SSL stream is currently open (i.e., handshake completed). More...
 
bool myOwnContext
 Track whether we own the SSL context (i.e., should delete it in destructor) Accepted client sockets will share the SSL context of the listening socket, so they do not own the context and should not delete it. More...
 
void * mySslContext
 opaque handles to avoid exposing boost types in header More...
 
void * mySslStream
 opaque handles to avoid exposing boost types in header More...
 
- Protected Attributes inherited from DtInetTcpSocket
void * myIoService
 
void * myTcpSocket
 
void * myTcpAcceptor
 
DtInetUtils::DtInetAddrFamily myAddrFamily
 
- Protected Attributes inherited from DtInetSocket
DtInetEndpoint myLocalEndpoint
 
DtInetEndpoint myRemoteEndpoint
 
DtInetDevice * myHostIf
 
DtInetSockState myState
 
DtU32 myFlags
 
bool myAsync
 
bool myNonBlockingEnabled
 
bool myNoDelayEnabled
 
bool myStartImmediately
 
int myErrorCode
 
DtString myErrorString
 
int myTerminationCode
 
DtString myTerminationString
 
DtInetSockCallbackList myPreRecvCallbacks
 
DtInetSockCallbackList myPostRecvCallbacks
 
DtInetSockCallbackList myPreSendCallbacks
 
DtInetSockCallbackList myPostSendCallbacks
 
DtU64 mySentByteCount
 
DtU64 mySentPacketCount
 
DtU64 myReceivedByteCount
 
DtU64 myReceivedPacketCount
 
DtTime myReceiveTime
 

Static Protected Attributes

static bool theClientCertRequired
 Wheter server sockets require client certificates for mutual authentication. Default is true. More...
 
static DtString theServerCRT
 Static members for default certificate paths and client cert requirement. More...
 
static DtString theServerKey
 Static members for default certificate paths and client cert requirement. More...
 
static DtString theClientCRT
 Static members for default certificate paths and client cert requirement. More...
 
static DtString theClientKey
 Static members for default certificate paths and client cert requirement. More...
 
static DtString theCaCRT
 Static members for default certificate paths and client cert requirement. More...
 
static DtString theCertificateFolder
 Folder to prepend to certificate file names if the file name is relative. More...
 

Constructor & Destructor Documentation

DtInetTlsSocket::DtInetTlsSocket ( )
DtInetTlsSocket::DtInetTlsSocket ( DtU16  localPort,
DtInetDevice *  hostIf = nullptr,
DtInetUtils::DtInetAddrFamily  family = DtInetUtils::DtInetAddrFamily_IPv4,
DtU32  flags = DtSockOptNoDelay,
bool  immediateOpen = true 
)

Server Socket Constructor.

Takes a port number to listen on, a pointer to the local network interface device the socket will be bound to, an address family indication (IPv4 or IPv6), socket option flags, and a trigger to open the socket immediately. If no host interface is specified the socket will be bound to INADDR_ANY (or IN6ADDR_ANY). If the 'immediateOpen' parameter is true the socket will immediately try to bind to an interface and listen for inbound connection attempts. New connections will not be automatically accepted if no socket addition callbacks are registered, therefore all new connections must be accepted by calling the acceptConnection() method. If the 'immediateOpen' parameter is false the socket will not start listening for connection attempts until the listenForConnections() method is invoked. Socket addition callbacks should be registered prior to invoking listen(). This ctor will not throw exceptions on failure. Check the socket status by calling state() (or isOk()) to determine if the socket is ready to use.

DtInetTlsSocket::DtInetTlsSocket ( const DtInetEndpoint &  dest,
DtU16  localPort = 0,
DtInetDevice *  hostIf = nullptr,
DtU32  flags = DtDefaultSockOpts,
bool  immediateOpen = true 
)

Interactive Socket Constructors.

Takes a DtInetEndpoint (containing the destination address, protocol - TCP or UDP, and destination port number), a source port number to use, a pointer to the local network interface device the socket will be bound to, socket option flags, and an 'immediateOpen' indicator dictating how the socket should behave upon creation. The address family (IPv4 or IPv6) is assumed from the destin- ation endpoint object. If the specified local port is 0 an ephemeral port will be chosen for the connection UNLESS the destination is a broadcast or multicast address, in which case the destination port is used as the local port also. If no host interface is specified the most appropriate interface will be chosen based on the destination. If the destination endpoint specifies a multicast address the multicast group is joined automatically when the socket is opened and the group member- ship is dropped when the socket is closed. If the 'immediateOpen' parameter is true the socket will immediately try to bind to an interface and connect to the destination (TCP sockets) or allow datagrams to be sent and received (UDP) using the default packet handlers which perform no parsing of packets. To use custom packet handlers for TCP send and receive functions set 'immediateOpen' to false when using this ctor, then configure the packet handler callbacks, then call connectToDestination(). To use custom packet handlers for UDP send and receive functions set 'immediateOpen' to false, configure the packet handler callbacks, then call openSocket() or connectToDestination() if the UDP socket will only communicate with a single remote host. This ctor will not throw exceptions on failure. Check the socket status by calling state() (or isOk()) to determine if the socket is ready.

virtual DtInetTlsSocket::~DtInetTlsSocket ( )
virtual

Member Function Documentation

virtual bool DtInetTlsSocket::acceptConnection ( DtInetTcpSocket *  peer,
DtU32  flags = DtDefaultSockOpts 
)
overridevirtual

Use TCP base for destination, binding, and options.

Reimplemented from DtInetTcpSocket.

virtual bool DtInetTlsSocket::buildCertificateFilePath ( DtFilename &  certFilename)
protectedvirtual

Build the file path for the certificate file, prepending the certificate folder if the file name is relative.

Checks if the resulting file path exists and is readable. Returns true on success; otherwise, false.

static const DtString& DtInetTlsSocket::caCRT ( )
static
static const DtString& DtInetTlsSocket::certificateFolder ( )
static
static bool DtInetTlsSocket::clientCertRequired ( )
static
static const DtString& DtInetTlsSocket::clientCRT ( )
static
static const DtString& DtInetTlsSocket::clientKey ( )
static
virtual bool DtInetTlsSocket::closeSocket ( )
overridevirtual

Use TCP base for destination, binding, and options.

Reimplemented from DtInetTcpSocket.

virtual unsigned DtInetTlsSocket::descriptor ( ) const
overridevirtual

Use TCP base for destination, binding, and options.

Reimplemented from DtInetTcpSocket.

virtual bool DtInetTlsSocket::handshakeDestination ( )
virtual

Perform SSL handshake after TCP connection is established.

Returns true on successful handshake; otherwise, false.

virtual bool DtInetTlsSocket::initClientSslContext ( )
protectedvirtual
virtual bool DtInetTlsSocket::initSslForListening ( )
protectedvirtual

Initialize SSL context for server/listening sockets. Returns true on success.

virtual bool DtInetTlsSocket::listenForConnections ( )
overridevirtual

Use TCP base for destination, binding, and options.

Reimplemented from DtInetTcpSocket.

virtual bool DtInetTlsSocket::openSocket ( )
overridevirtual

Use TCP base for destination, binding, and options.

Reimplemented from DtInetTcpSocket.

virtual DtInetSockRcvStatus DtInetTlsSocket::recv ( caddr_t  buff,
size_t  buffSize,
DtU32  flags = 0 
)
overridevirtual

Use TCP base for destination, binding, and options.

Reimplemented from DtInetTcpSocket.

virtual DtInetSockRcvStatus DtInetTlsSocket::recvFrom ( caddr_t  buff,
size_t  buffSize,
DtInetEndpoint &  src,
DtU32  flags = 0 
)
overridevirtual

Use TCP base for destination, binding, and options.

Reimplemented from DtInetTcpSocket.

virtual DtInetSockRcvStatus DtInetTlsSocket::recvToChain ( DtInetBufferChain &  packets,
DtU32  flags = 0 
)
overridevirtual

Use TCP base for destination, binding, and options.

Reimplemented from DtInetTcpSocket.

virtual DtInetSockRcvStatus DtInetTlsSocket::recvToChainFrom ( DtInetBufferChain &  packets,
DtInetEndpoint &  src,
DtU32  flags = 0 
)
overridevirtual

Use TCP base for destination, binding, and options.

Reimplemented from DtInetTcpSocket.

virtual int DtInetTlsSocket::send ( caddr_t  packet,
size_t  size,
DtU32  flags = 0 
)
overridevirtual

Use TCP base for destination, binding, and options.

Reimplemented from DtInetTcpSocket.

virtual int DtInetTlsSocket::sendChain ( DtInetBufferChain &  packets,
DtU32  flags = 0 
)
overridevirtual

Use TCP base for destination, binding, and options.

Reimplemented from DtInetTcpSocket.

virtual int DtInetTlsSocket::sendChainTo ( DtInetBufferChain &  packets,
DtInetEndpoint &  dest,
DtU32  flags = 0 
)
overridevirtual

Use TCP base for destination, binding, and options.

Reimplemented from DtInetTcpSocket.

virtual int DtInetTlsSocket::sendTo ( caddr_t  packet,
size_t  size,
DtInetEndpoint &  dest,
DtU32  flags = 0 
)
overridevirtual

Use TCP base for destination, binding, and options.

Reimplemented from DtInetTcpSocket.

static const DtString& DtInetTlsSocket::serverCRT ( )
static
static const DtString& DtInetTlsSocket::serverKey ( )
static
static void DtInetTlsSocket::setCaCRT ( const DtString &  crt)
static
static void DtInetTlsSocket::setCertificateFolder ( const DtString &  folder)
static
static void DtInetTlsSocket::setClientCertRequired ( bool  required)
static
static void DtInetTlsSocket::setClientCRT ( const DtString &  crt)
static
static void DtInetTlsSocket::setClientKey ( const DtString &  key)
static
virtual bool DtInetTlsSocket::setDestination ( const DtInetEndpoint &  addr)
overridevirtual

Use TCP base for destination, binding, and options.

Reimplemented from DtInetTcpSocket.

static void DtInetTlsSocket::setServerCRT ( const DtString &  crt)
static
static void DtInetTlsSocket::setServerKey ( const DtString &  key)
static
virtual bool DtInetTlsSocket::setSocket ( const DtInetEndpoint &  dest,
DtU16  localPort = 0,
DtInetDevice *  hostIf = nullptr,
DtU32  flags = DtDefaultSockOpts 
)
overridevirtual

Use TCP base for destination, binding, and options.

Reimplemented from DtInetTcpSocket.

Member Data Documentation

bool DtInetTlsSocket::myOwnContext
protected

Track whether we own the SSL context (i.e., should delete it in destructor) Accepted client sockets will share the SSL context of the listening socket, so they do not own the context and should not delete it.

void* DtInetTlsSocket::mySslContext
protected

opaque handles to avoid exposing boost types in header

void* DtInetTlsSocket::mySslStream
protected

opaque handles to avoid exposing boost types in header

bool DtInetTlsSocket::myStreamIsOpen
protected

Track whether the SSL stream is currently open (i.e., handshake completed).

This is needed to determine whether we can send/receive data and to prevent certain operations like changing the destination or closing the socket while the stream is open.

DtString DtInetTlsSocket::theCaCRT
staticprotected

Static members for default certificate paths and client cert requirement.

These can be set by the application before creating any TLS sockets to specify the default certificates to use for server and client sockets, and whether client certs are required by default for server sockets.

DtString DtInetTlsSocket::theCertificateFolder
staticprotected

Folder to prepend to certificate file names if the file name is relative.

If the file name is absolute or the folder is empty, the file name is used as-is. Default is empty, which means certs must be in the working directory or reset with appropriate paths.

bool DtInetTlsSocket::theClientCertRequired
staticprotected

Wheter server sockets require client certificates for mutual authentication. Default is true.

DtString DtInetTlsSocket::theClientCRT
staticprotected

Static members for default certificate paths and client cert requirement.

These can be set by the application before creating any TLS sockets to specify the default certificates to use for server and client sockets, and whether client certs are required by default for server sockets.

DtString DtInetTlsSocket::theClientKey
staticprotected

Static members for default certificate paths and client cert requirement.

These can be set by the application before creating any TLS sockets to specify the default certificates to use for server and client sockets, and whether client certs are required by default for server sockets.

DtString DtInetTlsSocket::theServerCRT
staticprotected

Static members for default certificate paths and client cert requirement.

These can be set by the application before creating any TLS sockets to specify the default certificates to use for server and client sockets, and whether client certs are required by default for server sockets.

DtString DtInetTlsSocket::theServerKey
staticprotected

Static members for default certificate paths and client cert requirement.

These can be set by the application before creating any TLS sockets to specify the default certificates to use for server and client sockets, and whether client certs are required by default for server sockets.


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

Document ID: Generated on Mon Sep 28 00:09:32 EDT 2026 from SVN revision 295353
Copyright © 1992-2025 MAK Technologies. All Rights Reserved (www.mak.com)