MAK RTIspy API Documentation for HLA Evolved
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
List of all members | Public Member Functions | Protected Attributes | Private Member Functions
DtPeerToPeerTcpSockMgr Class Reference

The DtPeerToPeerTcpSockMgr adds the ability to act as a client as well as a server to the DtTcpMsgSocketMgr base class. More...

+ Inheritance diagram for DtPeerToPeerTcpSockMgr:
+ Collaboration diagram for DtPeerToPeerTcpSockMgr:

Public Member Functions

 DtPeerToPeerTcpSockMgr (int port, DtBoost::shared_ptr< DtMsgHeaderReader > hdrRdr, size_t recvBufferSize, int maxForwarderQueue, int reconnectTries=0, float reconnectDelay=0.0f)
 Constructor, networkInterface defaults to INADDR_ANY. More...
 
virtual ~DtPeerToPeerTcpSockMgr ()
 Destructor. More...
 
virtual DtTcpMsgSocketconnectToPeer (const MAKRti::DtInetAddr &addr, DtInetDevice *hostIf=0)
 Establish a new connection to a remote host at port = myPort. More...
 
virtual DtTcpMsgSocketconnectToPeer (const MAKRti::DtInetAddr &addr, int port, DtInetDevice *hostIf=0)
 Establish a new connection to a remote host at port Returns a socket pending connection (ie - may not be fully connected yet) (returned socket will be valid but unusable until non-blocking conn status can be resolved) More...
 
virtual void removeAndDeletePeerConnection (DtTcpMsgSocket *sock, bool abort=true)
 Remove a peer socket connection (may still be pending) More...
 
unsigned int abortPendingConnections ()
 Remove all pending peer sockets. More...
 
unsigned int pendingConnectionsAborted ()
 Return count of aborted connections. More...
 
virtual bool repairPeerSocket (DtTcpMsgSocket *oldSock)
 
virtual void processConnections ()
 Check to see if any clients or peers are trying to connect. More...
 
void unlockProcessConnections ()
 
void lockProcessConnections ()
 
virtual void addSocketEstablishedCallback (DtSocketEstablishedCallback cb, void *usr)
 Call this method when a new socket connection is established to add a callback to the socket established function which will be called when a new socket connection is accepted and vetted. More...
 
virtual void removeSocketEstablishedCallback (DtSocketEstablishedCallback cb, void *usr)
 Call this method when a socket connection is deleted to remove the callback to the socket established function which was added when the connection was created. More...
 
- Public Member Functions inherited from DtTcpMsgSocketMgr
 DtTcpMsgSocketMgr (DtBoost::shared_ptr< DtMsgHeaderReader > hdrReader, size_t recvBufferSize=20000, int maxQueuedMsgs=-1)
 Constructor. Will not open a server socket. More...
 
virtual ~DtTcpMsgSocketMgr ()
 Destructor. More...
 
virtual bool openServerSocket (DtU16 localPort, DtInetDevice *hostIf=NULL, DtInetUtils::DtInetAddrFamily family=DtInetUtils::DtInetAddrFamily_IPv4, DtU32 flags=(DtDefaultSockOpts|DtSockOptNonBlocking))
 Opens a server socket if not already open. More...
 
void processNewConnections ()
 
virtual void addSocket (DtTcpMsgSocket *sock)
 Add a new socket to be managed that was created and opened outside of this class. More...
 
bool socketAdded (DtInetSocket *sock)
 
DtTcpMsgSocketMap::iterator checkIfReconnecting (const DtInetTcpSocket *newSock)
 
bool socketRemoved (DtInetSocket *sock)
 
virtual void removeAndDelete (DtTcpMsgSocket *sock)
 Remove the specified socket from the list and delete it. More...
 
virtual void enableBundling (size_t maxBundleSize)
 Enables message bundling and sets the maximum bundle size. More...
 
virtual void disableBundling ()
 Disables message bundling. More...
 
virtual void enableCompression (DtU8 compressionLevel)
 Enables message compression and sets the compression level. More...
 
virtual void disableCompression ()
 Disables message compression. More...
 
virtual void setTcpNoDelay (bool enable)
 Changes the setting of the TCP_NODELAY option. More...
 
virtual void setSendBufferSize (DtU32 size)
 Sets the socket send buffer size. More...
 
virtual void setRecvBufferSize (DtU32 size)
 Sets the socket receive buffer size. More...
 
virtual DtInetSockState serverSocketState () const
 Returns the state of the server socket. More...
 
virtual DtU32 maxMsgSize () const
 Gets the maximum message size. More...
 
DtTcpMsgSocketMapsocketSet ()
 Returns the list of sockets managed by this manager. More...
 
DtTcpMsgSocketMap::iterator socketIter (DtTcpMsgSocket *sock)
 Returns the iterator for the given socket, if the socket is managed by this manager. More...
 
DtString getLastError () const
 Get a description of the last error. More...
 
bool isListening () const
 Returns true if the socket is open. More...
 
virtual void addSocketAdditionCallback (DtTcpSocketAdditionCallback cb, void *usr)
 
virtual void removeSocketAdditionCallback (DtTcpSocketAdditionCallback cb, void *usr)
 
virtual void addSocketRemovalCallback (DtTcpSocketRemovalCallback cb, void *usr)
 
virtual void removeSocketRemovalCallback (DtTcpSocketRemovalCallback cb, void *usr)
 

Protected Attributes

int myPort
 Data Members. More...
 
MAKRti::DtClock myClock
 Clock used for socket timeouts. More...
 
unsigned int myPendingConnectionsAborted
 Count of socket connections which were aborted before successful establishment. More...
 
std::map< DtTcpMsgSocket
*, MAKRti::DtTime > 
myPendingConnections
 Map of outgoing peer connections that have not been fully established to the time at which they were initiated. More...
 
bool myProcessingConnections
 When processing an add connection callback, prevent recursive connection processing. More...
 
std::list< DtSocketCbInfomyEstablishedCallbacks
 list of callbacks to call when sockets become established More...
 
int myReconnectTries
 The number of times it will try to repair a socket via reconnect if a TCP connection is lost. More...
 
float myReconnectDelay
 The time it will try to sleep (seconds) between reconnect tries. More...
 
- Protected Attributes inherited from DtTcpMsgSocketMgr
std::auto_ptr< DtInetSocketMgr > mySocketMgr
 The underlying socket manager. More...
 
DtTcpMsgSocketMap mySockets
 List of sockets managed by this manager, mapped by the underlying DtInetTcpSocket. More...
 
DtBoost::shared_ptr
< DtMsgHeaderReader
myHeaderReader
 The message header reader to be used by all managed sockets. More...
 
int myMaxQueuedMessages
 The maximum size the send queue for each socket is allowed to reach. More...
 
size_t myRecvBufferSize
 The size of the sockets' receive buffers. More...
 
bool myTcpNoDelay
 The sockets' TCP_NODELAY setting. More...
 
size_t myMaxBundleSize
 The maximum size of outgoing message bundles. More...
 
MAKRti::DtU8 myCompressionLevel
 The maximum size of outgoing message bundles. More...
 
MAKRti::DtU32 mySockRecvBufferSize
 The receive buffer size for managed sockets. More...
 
MAKRti::DtU32 mySockSendBufferSize
 The send buffer size for managed sockets. More...
 
std::list< DtTcpSocketMgrCbInfomyAdditionCallbacks
 Socket addition callbacks. More...
 
std::list< DtTcpSocketMgrCbInfomyRemovalCallbacks
 Socket removal callbacks. More...
 
DtString myLastError
 Description of the last error. More...
 

Private Member Functions

 DtPeerToPeerTcpSockMgr (const DtPeerToPeerTcpSockMgr &orig)
 Copy Constructor and Assignment operator not implemented. Copy not allowed. More...
 
DtPeerToPeerTcpSockMgroperator= (const DtPeerToPeerTcpSockMgr &orig)
 

Additional Inherited Members

- Static Public Member Functions inherited from DtTcpMsgSocketMgr
static bool socketAdded (DtInetSocket *sock, void *usr)
 Callback handler for socket addition callbacks from DtInetSocketMgr. More...
 
static bool socketRemoved (DtInetSocket *sock, void *usr)
 Callback handler for socket removal callbacks from DtInetSocketMgr. More...
 

Detailed Description

The DtPeerToPeerTcpSockMgr adds the ability to act as a client as well as a server to the DtTcpMsgSocketMgr base class.

This socket manager is able to actively create socket connections as well as passively listen. It also supports creation of specialized sockets. All socket addition and removal callbacks will be called for actively opened connections as well as incoming connections.

Constructor & Destructor Documentation

DtPeerToPeerTcpSockMgr::DtPeerToPeerTcpSockMgr ( int  port,
DtBoost::shared_ptr< DtMsgHeaderReader hdrRdr,
size_t  recvBufferSize,
int  maxForwarderQueue,
int  reconnectTries = 0,
float  reconnectDelay = 0.0f 
)

Constructor, networkInterface defaults to INADDR_ANY.

virtual DtPeerToPeerTcpSockMgr::~DtPeerToPeerTcpSockMgr ( )
virtual

Destructor.

DtPeerToPeerTcpSockMgr::DtPeerToPeerTcpSockMgr ( const DtPeerToPeerTcpSockMgr orig)
private

Copy Constructor and Assignment operator not implemented. Copy not allowed.

Member Function Documentation

unsigned int DtPeerToPeerTcpSockMgr::abortPendingConnections ( )

Remove all pending peer sockets.

virtual void DtPeerToPeerTcpSockMgr::addSocketEstablishedCallback ( DtSocketEstablishedCallback  cb,
void *  usr 
)
virtual

Call this method when a new socket connection is established to add a callback to the socket established function which will be called when a new socket connection is accepted and vetted.

virtual DtTcpMsgSocket* DtPeerToPeerTcpSockMgr::connectToPeer ( const MAKRti::DtInetAddr &  addr,
DtInetDevice *  hostIf = 0 
)
virtual

Establish a new connection to a remote host at port = myPort.

virtual DtTcpMsgSocket* DtPeerToPeerTcpSockMgr::connectToPeer ( const MAKRti::DtInetAddr &  addr,
int  port,
DtInetDevice *  hostIf = 0 
)
virtual

Establish a new connection to a remote host at port Returns a socket pending connection (ie - may not be fully connected yet) (returned socket will be valid but unusable until non-blocking conn status can be resolved)

void DtPeerToPeerTcpSockMgr::lockProcessConnections ( )
inline
DtPeerToPeerTcpSockMgr& DtPeerToPeerTcpSockMgr::operator= ( const DtPeerToPeerTcpSockMgr orig)
private
unsigned int DtPeerToPeerTcpSockMgr::pendingConnectionsAborted ( )

Return count of aborted connections.

virtual void DtPeerToPeerTcpSockMgr::processConnections ( )
virtual

Check to see if any clients or peers are trying to connect.

If so, add new DtTcpSockets to handle the connections. Check to see if any pending outgoing connections have been established. If so, add them to the list of connections.

Reimplemented from DtTcpMsgSocketMgr.

virtual void DtPeerToPeerTcpSockMgr::removeAndDeletePeerConnection ( DtTcpMsgSocket sock,
bool  abort = true 
)
virtual

Remove a peer socket connection (may still be pending)

virtual void DtPeerToPeerTcpSockMgr::removeSocketEstablishedCallback ( DtSocketEstablishedCallback  cb,
void *  usr 
)
virtual

Call this method when a socket connection is deleted to remove the callback to the socket established function which was added when the connection was created.

virtual bool DtPeerToPeerTcpSockMgr::repairPeerSocket ( DtTcpMsgSocket oldSock)
virtual
void DtPeerToPeerTcpSockMgr::unlockProcessConnections ( )
inline

Member Data Documentation

MAKRti::DtClock DtPeerToPeerTcpSockMgr::myClock
protected

Clock used for socket timeouts.

std::list<DtSocketCbInfo> DtPeerToPeerTcpSockMgr::myEstablishedCallbacks
protected

list of callbacks to call when sockets become established

std::map<DtTcpMsgSocket*, MAKRti::DtTime> DtPeerToPeerTcpSockMgr::myPendingConnections
protected

Map of outgoing peer connections that have not been fully established to the time at which they were initiated.

unsigned int DtPeerToPeerTcpSockMgr::myPendingConnectionsAborted
protected

Count of socket connections which were aborted before successful establishment.

int DtPeerToPeerTcpSockMgr::myPort
protected

Data Members.

The Listening port and default port for peer connections

bool DtPeerToPeerTcpSockMgr::myProcessingConnections
protected

When processing an add connection callback, prevent recursive connection processing.

float DtPeerToPeerTcpSockMgr::myReconnectDelay
protected

The time it will try to sleep (seconds) between reconnect tries.

int DtPeerToPeerTcpSockMgr::myReconnectTries
protected

The number of times it will try to repair a socket via reconnect if a TCP connection is lost.


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

Document ID: Generated on Thu May 11 15:55:32 EDT 2023 from SVN revision 254743
Copyright © 2005-2020 MAK Technologies Inc. All Rights Reserved (www.mak.com)