MAK RTIspy API Documentation for HLA 1516
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)
 Constructor, networkInterface defaults to INADDR_ANY.
virtual ~DtPeerToPeerTcpSockMgr ()
 Destructor.
virtual DtTcpMsgSocketconnectToPeer (const MAKRti::DtInetAddr &addr, DtInetDevice *hostIf=0)
 Establish a new connection to a remote host at port = myPort.
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)
virtual void removeAndDeletePeerConnection (DtTcpMsgSocket *sock, bool abort=true)
 Remove a peer socket connection (may still be pending)
unsigned int abortPendingConnections ()
 Remove all pending peer sockets.
unsigned int pendingConnectionsAborted ()
 Return count of aborted connections.
virtual void processConnections ()
 Check to see if any clients or peers are trying to connect.
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.
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.
- 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.
virtual ~DtTcpMsgSocketMgr ()
 Destructor.
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.
virtual void addSocket (DtTcpMsgSocket *sock)
 Add a new socket to be managed that was created and opened outside of this class.
bool socketAdded (DtInetSocket *sock)
bool socketRemoved (DtInetSocket *sock)
virtual void removeAndDelete (DtTcpMsgSocket *sock)
 Remove the specified socket from the list and delete it.
virtual void enableBundling (size_t maxBundleSize)
 Enables message bundling and sets the maximum bundle size.
virtual void disableBundling ()
 Disables message bundling.
virtual void enableCompression (DtU8 compressionLevel)
 Enables message compression and sets the compression level.
virtual void disableCompression ()
 Disables message compression.
virtual void setTcpNoDelay (bool enable)
 Changes the setting of the TCP_NODELAY option.
virtual void setSendBufferSize (DtU32 size)
 Sets the socket send buffer size.
virtual void setRecvBufferSize (DtU32 size)
 Sets the socket receive buffer size.
virtual DtInetSockState serverSocketState () const
 Returns the state of the server socket.
virtual DtU32 maxMsgSize () const
 Gets the maximum message size.
DtTcpMsgSocketMapsocketSet ()
 Returns the list of sockets managed by this manager.
DtTcpMsgSocketMap::iterator socketIter (DtTcpMsgSocket *sock)
 Returns the iterator for the given socket, if the socket is managed by this manager.
DtString getLastError () const
 Get a description of the last error.
bool isListening () const
 Returns true if the socket is open.
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.
MAKRti::DtClock myClock
 Clock used for socket timeouts.
unsigned int myPendingConnectionsAborted
 Count of socket connections which were aborted before successful establishment.
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.
bool myProcessingConnections
 When processing an add connection callback, prevent recursive connection processing.
std::list< DtSocketCbInfomyEstablishedCallbacks
 list of callbacks to call when sockets become established
- Protected Attributes inherited from DtTcpMsgSocketMgr
std::auto_ptr< DtInetSocketMgr > mySocketMgr
 The underlying socket manager.
DtTcpMsgSocketMap mySockets
 List of sockets managed by this manager, mapped by the underlying DtInetTcpSocket.
DtBoost::shared_ptr
< DtMsgHeaderReader
myHeaderReader
 The message header reader to be used by all managed sockets.
int myMaxQueuedMessages
 The maximum size the send queue for each socket is allowed to reach.
size_t myRecvBufferSize
 The size of the sockets' receive buffers.
bool myTcpNoDelay
 The sockets' TCP_NODELAY setting.
size_t myMaxBundleSize
 The maximum size of outgoing message bundles.
MAKRti::DtU8 myCompressionLevel
 The maximum size of outgoing message bundles.
MAKRti::DtU32 mySockRecvBufferSize
 The receive buffer size for managed sockets.
MAKRti::DtU32 mySockSendBufferSize
 The send buffer size for managed sockets.
std::list< DtTcpSocketMgrCbInfomyAdditionCallbacks
 Socket addition callbacks.
std::list< DtTcpSocketMgrCbInfomyRemovalCallbacks
 Socket removal callbacks.
DtString myLastError
 Description of the last error.

Private Member Functions

 DtPeerToPeerTcpSockMgr (const DtPeerToPeerTcpSockMgr &orig)
 Copy Constructor and Assignment operator not implemented. Copy not allowed.
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.
static bool socketRemoved (DtInetSocket *sock, void *usr)
 Callback handler for socket removal callbacks from DtInetSocketMgr.

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 
)

Constructor, networkInterface defaults to INADDR_ANY.

References myClock.

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 ( )
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.

References myEstablishedCallbacks.

Referenced by DtInOutForwarderPort::DtInOutForwarderPort().

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

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

References myPort.

Referenced by DtInOutForwarderPort::addSocketUsingRoutesFile(), and DtInOutForwarderPort::connectToPeer().

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

Return count of aborted connections.

References myPendingConnectionsAborted.

Referenced by DtInOutForwarderPort::pendingConnectionsAborted().

void DtPeerToPeerTcpSockMgr::processConnections ( )
virtual
void DtPeerToPeerTcpSockMgr::removeAndDeletePeerConnection ( DtTcpMsgSocket sock,
bool  abort = true 
)
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.

References myEstablishedCallbacks.

Referenced by DtInOutForwarderPort::~DtInOutForwarderPort().

Member Data Documentation

MAKRti::DtClock DtPeerToPeerTcpSockMgr::myClock
protected

Clock used for socket timeouts.

Referenced by connectToPeer(), and DtPeerToPeerTcpSockMgr().

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

list of callbacks to call when sockets become established

Referenced by addSocketEstablishedCallback(), processConnections(), and removeSocketEstablishedCallback().

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.

Referenced by abortPendingConnections(), connectToPeer(), processConnections(), and removeAndDeletePeerConnection().

unsigned int DtPeerToPeerTcpSockMgr::myPendingConnectionsAborted
protected

Count of socket connections which were aborted before successful establishment.

Referenced by abortPendingConnections(), pendingConnectionsAborted(), processConnections(), and removeAndDeletePeerConnection().

int DtPeerToPeerTcpSockMgr::myPort
protected

Data Members.

The Listening port and default port for peer connections

Referenced by connectToPeer().

bool DtPeerToPeerTcpSockMgr::myProcessingConnections
protected

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

Referenced by processConnections().


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

Document ID: Generated on Tue May 7 16:26:47 EDT 2013 from SVN revision 126903
Copyright © 2005-2013 VT MÄK Inc. All Rights Reserved (www.mak.com)