![]() |
MAK RTIspy API Documentation for HLA 1.3
|
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 DtTcpMsgSocket * | connectToPeer (const MAKRti::DtInetAddr &addr, DtInetDevice *hostIf=0) |
| Establish a new connection to a remote host at port = myPort. More... | |
| virtual DtTcpMsgSocket * | connectToPeer (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... | |
| DtTcpMsgSocketMap & | socketSet () |
| 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< DtSocketCbInfo > | myEstablishedCallbacks |
| 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< DtTcpSocketMgrCbInfo > | myAdditionCallbacks |
| Socket addition callbacks. More... | |
| std::list< DtTcpSocketMgrCbInfo > | myRemovalCallbacks |
| 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... | |
| DtPeerToPeerTcpSockMgr & | operator= (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... | |
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.
| 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 |
Destructor.
|
private |
Copy Constructor and Assignment operator not implemented. Copy not allowed.
| unsigned int DtPeerToPeerTcpSockMgr::abortPendingConnections | ( | ) |
Remove all pending peer sockets.
|
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 |
Establish a new connection to a remote host at port = myPort.
|
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)
|
inline |
|
private |
| unsigned int DtPeerToPeerTcpSockMgr::pendingConnectionsAborted | ( | ) |
Return count of aborted connections.
|
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 |
Remove a peer socket connection (may still be pending)
|
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 |
|
inline |
|
protected |
Clock used for socket timeouts.
|
protected |
list of callbacks to call when sockets become established
|
protected |
Map of outgoing peer connections that have not been fully established to the time at which they were initiated.
|
protected |
Count of socket connections which were aborted before successful establishment.
|
protected |
Data Members.
The Listening port and default port for peer connections
|
protected |
When processing an add connection callback, prevent recursive connection processing.
|
protected |
The time it will try to sleep (seconds) between reconnect tries.
|
protected |
The number of times it will try to repair a socket via reconnect if a TCP connection is lost.