![]() |
MAK RTIspy API Documentation for HLA Evolved
|
The DtTcpMsgSocket class provides an address family independent TCP socket that handles RTI messages. More...
Inheritance diagram for DtTcpMsgSocket:
Collaboration diagram for DtTcpMsgSocket:Public Member Functions | |
| DtTcpMsgSocket (DtBoost::shared_ptr< DtMsgHeaderReader > hdrReader, size_t recvBufferSize=20000, int maxQueuedMsgs=-1) | |
| Constructor. | |
| DtTcpMsgSocket (std::auto_ptr< DtInetTcpSocket > socket, DtBoost::shared_ptr< DtMsgHeaderReader > hdrReader, size_t recvBuffSize=20000, int maxQueuedMsgs=-1) | |
| Constructor which takes a pre-created DtInetTcpSocket pointer. | |
| virtual | ~DtTcpMsgSocket () |
| Destructor. | |
| virtual void | openServerSocket (DtU16 localPort, DtU32 flags=DtDefaultSockOpts, DtInetDevice *hostIf=NULL, DtInetUtils::DtInetAddrFamily family=DtInetUtils::DtInetAddrFamily_IPv4) |
| Opens a server socket if not already open. | |
| virtual void | openClientSocket (const DtInetEndpoint &dest, DtU32 flags=DtDefaultSockOpts, DtU16 localPort=0, DtInetDevice *hostIf=NULL) |
| Opens a client socket if not already open. | |
| virtual int | sendMessage (caddr_t msg, size_t msgSize, bool deleteAfterSend, const DtInetAddr &destAddr=DtInetAddr::inaddrAny()) |
| Sends a message, queuing it up if the receiver's buffer is full. | |
| virtual bool | flush () |
| Attempts to send any queued messages and bundled messages. | |
| virtual int | recvMessage (caddr_t *buffptr) |
| Gets the next message from the stream of incoming data. | |
| virtual int | recvMessageWithSrc (caddr_t *buffptr, DtInetEndpoint &src) |
| Gets the next message from the stream of incoming data. | |
| virtual void | enableBundling (size_t maxBundleSize) |
| Enables message bundling and sets the maximum bundle size. | |
| virtual void | disableBundling () |
| Disables message bundling. | |
| virtual unsigned | bundleSize () const |
| Returns the bundle size, or 0 if bundling disabled. | |
| virtual void | enableCompression (DtU8 compressionLevel) |
| Enables message compression and sets the compression level. | |
| virtual void | disableCompression () |
| Disables message compression. | |
| virtual unsigned | compressionLevel () const |
| Returns the compression level, or 0 if compression disabled. | |
| virtual bool | testConnectionStatus () |
| virtual void | setMaxQueuedMessages (int size) |
| Sets the maximum number of messages that can be queued. | |
| virtual int | maxQueuedMessages () const |
| Returns the maximum number of messages that can be queued. | |
| virtual bool | getQueueStatus (int &percentFull) const |
| Gets the percentage full of the message queue. | |
| virtual void | setTcpNoDelay (bool enable) |
| Changes the setting of TCP_NODELAY. | |
| virtual void | setNonBlocking (bool nonBlocking) |
| Makes the socket non-blocking or blocking. | |
| virtual const DtInetEndpoint & | destination () const |
| Returns the destination endpoint of this socket. | |
| virtual DtU32 | maxMsgSize () const |
| Gets the maximum message size. | |
| DtInetTcpSocket * | inetTcpSocket () |
| Returns a pointer to the DtInetTcpSocket. | |
| bool | isConnected () const |
| Returns true if the socket is connected. | |
| bool | isConnectionInProgress () const |
| Returns true if the socket is in the process of connecting. | |
Public Member Functions inherited from DtMsgSocket | |
| DtMsgSocket (DtBoost::shared_ptr< DtMsgHeaderReader > hdrReader, size_t recvBuffSize) | |
| Constructor. | |
| DtMsgSocket (std::auto_ptr< DtInetSocket > socket, DtBoost::shared_ptr< DtMsgHeaderReader > hdrReader, size_t recvBuffSize) | |
| Constructor which takes a pre-created DtInetSocket pointer. | |
| virtual | ~DtMsgSocket () |
| Destructor. | |
| virtual bool | closeSocket () |
| Close a socket. Returns true on successful close or false on failure. | |
| virtual DtInetSockState | state () const |
| Returns the state of the socket. | |
| void | printStateToStream (MAKRti::DtOutputStream &stream) const |
| prints state to stream | |
| const DtString & | lastError () const |
| Returns a description of the last error. | |
| const DtInetEndpoint & | localEndpoint () const |
| Gets the local endpoint for the socket. | |
| void | setSendBufferSize (DtU32 size) |
| Sets the socket send buffer size. | |
| void | setRecvBufferSize (DtU32 size) |
| Sets the socket receive buffer size. | |
| DtU32 | maxSendMsgSize () const |
| Gets the maximum socket send size. | |
| int | descriptor () const |
| Get's the socket file descriptor. | |
| DtInetSocket * | inetSocket () |
| Returns a pointer to the DtInetSocket. | |
Protected Member Functions | |
| virtual int | sendData (caddr_t msg, size_t msgSize, bool deleteAfterSend) |
| Sends data on the socket, queues if it cannot be sent. | |
| virtual bool | flushQueue () |
| Attempts to send any queued messages. | |
| virtual bool | queueMessage (caddr_t msg, size_t msgSize) |
| Adds a message to the transmit queue. Returns true if successful. | |
| virtual void | resizeTestPacket () |
| Resizes the test packet used to test the connection. | |
Protected Member Functions inherited from DtMsgSocket | |
| void | expandRecvBuffer (size_t sizeNeeded) |
| Expands the receive buffer to accommodate the given size message. | |
Protected Attributes | |
| bool | myNeedSize |
| Whether we still need to receive the size field for the next/current message. | |
| int | myNumBytesToWaitFor |
| The number of bytes we are waiting for to complete the message. | |
| int | myNumBytesReceived |
| The number of bytes we have so far received for the current message. | |
| DtInetBuffer | myTestPacket |
| The buffer to store test packets in. | |
| std::list< DtQueuedMsg > | myMsgQueue |
| The queue of unsent messages. | |
| DtMsgBundler | myMsgBundler |
| Bundler for outgoing messages. | |
| bool | myBundlingEnabled |
| Whether message bundling is enabled. | |
| DtMsgCompressor | myMsgCompressor |
| Message compressor and uncompressor. | |
| bool | myCompressionEnabled |
| Whether message compression is enabled. | |
| int | myMaxQueuedMessages |
| The maximum size the send queue is allowed to reach. | |
| int | myMutableOldQueueLevel |
| The queue level the last time the user was notified of queue state. | |
| size_t | myBytesNeededForSize |
| The number of bytes needed to read the size from the message header. | |
Protected Attributes inherited from DtMsgSocket | |
| std::auto_ptr < MAKRti::DtInetSocket > | mySocket |
| The socket. | |
| DtInetBuffer | myRecvBuffer |
| The buffer to store received data in. | |
| DtString | myLastError |
| Description of last error. | |
| DtBoost::shared_ptr < DtMsgHeaderReader > | myHeaderReader |
| Reads data from message header. | |
The DtTcpMsgSocket class provides an address family independent TCP socket that handles RTI messages.
| DtTcpMsgSocket::DtTcpMsgSocket | ( | DtBoost::shared_ptr< DtMsgHeaderReader > | hdrReader, |
| size_t | recvBufferSize = 20000, |
||
| int | maxQueuedMsgs = -1 |
||
| ) |
Constructor.
Requires a header reader to extract information from message headers. Does NOT open the socket. A call to openServerSocket() or openClientSocket() is required.
References myBytesNeededForSize, myNumBytesToWaitFor, and resizeTestPacket().
| DtTcpMsgSocket::DtTcpMsgSocket | ( | std::auto_ptr< DtInetTcpSocket > | socket, |
| DtBoost::shared_ptr< DtMsgHeaderReader > | hdrReader, | ||
| size_t | recvBuffSize = 20000, |
||
| int | maxQueuedMsgs = -1 |
||
| ) |
Constructor which takes a pre-created DtInetTcpSocket pointer.
Gives ownership and responsibility of the socket to the DtTcpMsgSocket object.
References myBytesNeededForSize, myNumBytesToWaitFor, and resizeTestPacket().
|
virtual |
Destructor.
|
virtual |
Returns the bundle size, or 0 if bundling disabled.
References DtMsgBundler::maxSendBundleSize(), myBundlingEnabled, and myMsgBundler.
Referenced by flush(), DtFilteredTcpForwarder::readAndForward(), sendMessage(), DtInOutForwarderPort::sendToAllReliable(), and DtInOutForwarderPort::sendToListReliable().
|
virtual |
Returns the compression level, or 0 if compression disabled.
References DtMsgCompressor::compressionLevel(), myCompressionEnabled, and myMsgCompressor.
|
virtual |
Returns the destination endpoint of this socket.
References DtMsgSocket::mySocket.
Referenced by DtInOutForwarderPort::addConnection(), DtInOutForwarderPort::addSocketDynamically(), DtPeerToPeerTcpSockMgr::processConnections(), DtRtiExecTrackingFilter::processDisconnectMsg(), DtRtiExecTrackingFilter::processHandshakeMsg(), DtInOutForwarderPort::processPortMsg(), DtFilteredTcpForwarder::readAndForward(), DtRtiMsgForwarder::requestKillSingleConnection(), DtInOutForwarderPort::sendForwarderNodeInfoMsg(), DtInOutForwarderPort::sendMacAddrMsg(), DtInOutForwarderPort::socketAdditionCb(), DtInOutForwarderPort::socketEstablishedCb(), DtInOutForwarderPort::socketRemovalCb(), DtExtendedRtiMsgForwarder::tcpSocketAdditionCb(), DtRtiMsgForwarder::tcpSocketAdditionCb(), and DtExtendedRtiMsgForwarder::tcpSocketRemovalCb().
|
virtual |
|
virtual |
|
virtual |
Enables message bundling and sets the maximum bundle size.
Implements DtMsgSocket.
References myBundlingEnabled, myMsgBundler, and DtMsgBundler::setMaxSendBundleSize().
Referenced by DtInOutForwarderPort::connectionCompleted(), DtPeerToPeerTcpSockMgr::connectToPeer(), DtConnectionMgr::createAncillaryRelConns(), DtConnectionMgr::createRelConn(), and DtTcpMsgSocketMgr::socketAdded().
|
virtual |
Enables message compression and sets the compression level.
Implements DtMsgSocket.
References myCompressionEnabled, myMsgCompressor, and DtMsgCompressor::setCompressionLevel().
Referenced by DtInOutForwarderPort::connectionCompleted(), DtPeerToPeerTcpSockMgr::connectToPeer(), DtConnectionMgr::createAncillaryRelConns(), DtConnectionMgr::createRelConn(), and DtTcpMsgSocketMgr::socketAdded().
|
virtual |
Attempts to send any queued messages and bundled messages.
Returns true if all queued and bundled messages were sent.
Implements DtMsgSocket.
References bundleSize(), flushQueue(), DtMsgBundler::getBundle(), myBundlingEnabled, myMsgBundler, myMsgQueue, and sendData().
Referenced by DtExtendedRtiMsgForwarder::getNextMsg(), DtTcpForwarder__vl__::readAndForward(), DtFilteredTcpForwarder::readAndForward(), DtInOutForwarderPort::sendForwarderNodeInfoMsg(), DtInOutForwarderPort::sendMacAddrMsg(), DtRtiAssistantClient::sendMsgAndWait(), DtInOutForwarderPort::sendPortMsg(), DtInOutForwarderPort::sendToAllReliable(), DtInOutForwarderPort::sendToListReliable(), and DtRtiMsgForwarder::waitForIo().
|
protectedvirtual |
Attempts to send any queued messages.
Returns true if all queued messages were sent.
References myMsgQueue, and DtMsgSocket::mySocket.
Referenced by flush(), and sendData().
|
virtual |
Gets the percentage full of the message queue.
Return value indicates whether a threshold has been hit such that a user alert is necessary.
References myMaxQueuedMessages, myMsgQueue, and myMutableOldQueueLevel.
Referenced by DtFilteredTcpForwarder::sendToList().
|
inline |
Returns a pointer to the DtInetTcpSocket.
Referenced by DtTcpMsgSocketMgr::addSocket(), DtMessageFilter::addToSocketMap(), DtRtiAssistantServer::readAndProcess(), DtMessageFilter::removeFromSocketMap(), and DtTcpMsgSocketMgr::socketIter().
|
inline |
Returns true if the socket is connected.
Referenced by DtInOutForwarderPort::addSocketUsingRoutesFile(), DtInOutForwarderPort::checkConnectionStatus(), DtPeerToPeerTcpSockMgr::connectToPeer(), DtInOutForwarderPort::connectToPeer(), DtConnectionMgr::createAncillaryRelConns(), DtConnectionMgr::createRelConn(), DtInOutForwarderPort::getNextMsg(), DtExtendedRtiMsgForwarder::getNextMsg(), DtRtiAssistantClient::isConnected(), DtRtiAssistantClient::makeSingleConnectionAttempt(), DtRtiAssistantClient::netRead(), DtPeerToPeerTcpSockMgr::processConnections(), DtTcpForwarder__vl__::readAndForward(), DtRtiAssistantClient::readAndProcess(), DtRtiAssistantServer::readAndProcess(), DtInOutForwarderPort::sendForwarderNodeInfoMsg(), DtRtiAssistantClient::sendMsg(), DtRtiAssistantClient::sendMsgAndWait(), DtTcpForwarder__vl__::sendToAll(), DtInOutForwarderPort::sendToAllReliable(), DtFilteredTcpForwarder::sendToList(), DtInOutForwarderPort::sendToListReliable(), DtInOutForwarderPort::socketAdditionCb(), DtRtiExecConnectionState::testRtiExecConnectionStatus(), and DtRtiAssistantClient::tick().
|
inline |
Returns true if the socket is in the process of connecting.
Referenced by DtInOutForwarderPort::addSocketUsingRoutesFile(), DtPeerToPeerTcpSockMgr::connectToPeer(), DtInOutForwarderPort::connectToPeer(), and DtPeerToPeerTcpSockMgr::processConnections().
|
virtual |
Gets the maximum message size.
References DtMsgSocket::mySocket.
|
virtual |
Returns the maximum number of messages that can be queued.
A negative value indicates no limit is imposed.
References myMaxQueuedMessages.
|
virtual |
Opens a client socket if not already open.
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, and socket option flags. The address family (IPv4 or IPv6) is assumed from the dest 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. This ctor will not throw exceptions on failure. Check the socket status by calling state() to determine if the socket is ready.
References DtMsgSocket::myLastError, and DtMsgSocket::mySocket.
Referenced by DtPeerToPeerTcpSockMgr::connectToPeer(), DtConnectionMgr::createAncillaryRelConns(), DtConnectionMgr::createRelConn(), and DtRtiAssistantClient::makeSingleConnectionAttempt().
|
virtual |
Opens a server socket if not already open.
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). Socket will be opened immediately. This ctor will not throw exceptions on failure. Check the socket status by calling state() to determine if the socket is ready to use.
References DtMsgSocket::myLastError, and DtMsgSocket::mySocket.
|
protectedvirtual |
Adds a message to the transmit queue. Returns true if successful.
References DtMsgSocket::myLastError, myMaxQueuedMessages, and myMsgQueue.
Referenced by sendData().
|
virtual |
Gets the next message from the stream of incoming data.
Implements DtMsgSocket.
References DtMsgSocket::expandRecvBuffer(), DtMsgCompressor::isCompressed(), myBytesNeededForSize, DtMsgSocket::myHeaderReader, DtMsgSocket::myLastError, myMsgCompressor, myNeedSize, myNumBytesReceived, myNumBytesToWaitFor, DtMsgSocket::myRecvBuffer, DtMsgSocket::mySocket, and DtMsgCompressor::uncompressMsg().
Referenced by DtInOutForwarderPort::getNextMsg(), DtRtiAssistantClient::netRead(), DtRtiAssistantServer::netRead(), DtTcpForwarder__vl__::readAndForward(), DtFilteredTcpForwarder::readAndForward(), and recvMessageWithSrc().
|
virtual |
Gets the next message from the stream of incoming data.
Implements DtMsgSocket.
References DtMsgSocket::mySocket, and recvMessage().
|
protectedvirtual |
Resizes the test packet used to test the connection.
References myBytesNeededForSize, DtMsgSocket::myHeaderReader, and myTestPacket.
Referenced by DtTcpMsgSocket().
|
protectedvirtual |
Sends data on the socket, queues if it cannot be sent.
References flushQueue(), DtMsgSocket::myLastError, DtMsgSocket::mySocket, and queueMessage().
Referenced by flush(), and sendMessage().
|
virtual |
Sends a message, queuing it up if the receiver's buffer is full.
destAddr is ignored.
Implements DtMsgSocket.
References DtMsgBundler::addToBundle(), bundleSize(), DtMsgCompressor::compressMsg(), DtMsgBundler::getBundle(), myBundlingEnabled, myCompressionEnabled, DtMsgSocket::myLastError, myMsgBundler, myMsgCompressor, DtMsgSocket::mySocket, and sendData().
Referenced by DtInOutForwarderPort::sendForwarderNodeInfoMsg(), DtInOutForwarderPort::sendMacAddrMsg(), DtRtiAssistantClient::sendMsg(), DtRtiAssistantServer::sendMsg(), DtRtiAssistantClient::sendMsgAndWait(), DtInOutForwarderPort::sendPortMsg(), DtTcpForwarder__vl__::sendToAll(), DtInOutForwarderPort::sendToAllReliable(), DtFilteredTcpForwarder::sendToList(), DtInOutForwarderPort::sendToListReliable(), DtRtiMsgForwarder::tcpSocketAdditionCb(), and testConnectionStatus().
|
virtual |
Sets the maximum number of messages that can be queued.
A negative value indicates no limit is imposed.
References myMaxQueuedMessages.
|
virtual |
Makes the socket non-blocking or blocking.
References DtMsgSocket::mySocket.
Referenced by DtConnectionMgr::createAncillaryRelConns(), DtConnectionMgr::createRelConn(), and DtRtiAssistantClient::makeSingleConnectionAttempt().
|
virtual |
Changes the setting of TCP_NODELAY.
References DtMsgSocket::mySocket.
Referenced by DtTcpMsgSocketMgr::socketAdded().
|
virtual |
References false, myTestPacket, and sendMessage().
Referenced by DtInOutForwarderPort::checkConnectionStatus(), DtPeerToPeerTcpSockMgr::processConnections(), DtRtiAssistantClient::sendMsgAndWait(), DtInOutForwarderPort::socketAdditionCb(), DtRtiAssistantServer::testConnections(), DtRtiAssistantClient::testConnectionStatus(), and DtRtiAssistantClient::tick().
|
protected |
Whether message bundling is enabled.
Referenced by bundleSize(), disableBundling(), enableBundling(), flush(), and sendMessage().
|
protected |
The number of bytes needed to read the size from the message header.
Referenced by DtTcpMsgSocket(), recvMessage(), and resizeTestPacket().
|
protected |
Whether message compression is enabled.
Referenced by compressionLevel(), disableCompression(), enableCompression(), and sendMessage().
|
protected |
The maximum size the send queue is allowed to reach.
Referenced by getQueueStatus(), maxQueuedMessages(), queueMessage(), and setMaxQueuedMessages().
|
protected |
Bundler for outgoing messages.
Referenced by bundleSize(), enableBundling(), flush(), and sendMessage().
|
protected |
Message compressor and uncompressor.
Referenced by compressionLevel(), enableCompression(), recvMessage(), and sendMessage().
|
protected |
The queue of unsent messages.
Referenced by flush(), flushQueue(), getQueueStatus(), and queueMessage().
|
mutableprotected |
The queue level the last time the user was notified of queue state.
Mutable since this is solely to maintain internal state and needs to be modified by the const getQueueStatus() method.
Referenced by getQueueStatus().
|
protected |
Whether we still need to receive the size field for the next/current message.
Referenced by recvMessage().
|
protected |
The number of bytes we have so far received for the current message.
Referenced by recvMessage().
|
protected |
The number of bytes we are waiting for to complete the message.
Referenced by DtTcpMsgSocket(), and recvMessage().
|
protected |
The buffer to store test packets in.
Referenced by resizeTestPacket(), and testConnectionStatus().