![]() |
MAK RTIspy API Documentation for HLA 1516
|
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. | |
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 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. | |
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().
| DtTcpMsgSocket::~DtTcpMsgSocket | ( | ) | [virtual] |
Destructor.
| unsigned DtTcpMsgSocket::bundleSize | ( | ) | const [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().
| unsigned DtTcpMsgSocket::compressionLevel | ( | ) | const [virtual] |
Returns the compression level, or 0 if compression disabled.
References DtMsgCompressor::compressionLevel(), myCompressionEnabled, and myMsgCompressor.
| const DtInetEndpoint & DtTcpMsgSocket::destination | ( | ) | const [virtual] |
Returns the destination endpoint of this socket.
References DtMsgSocket::mySocket.
Referenced by DtInOutForwarderPort::addConnection(), DtInOutForwarderPort::addSocketDynamically(), DtTcpRtiConnectionMgr::establishConnection(), 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().
| void DtTcpMsgSocket::disableBundling | ( | ) | [virtual] |
| void DtTcpMsgSocket::disableCompression | ( | ) | [virtual] |
| void DtTcpMsgSocket::enableBundling | ( | size_t | maxBundleSize | ) | [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().
| void DtTcpMsgSocket::enableCompression | ( | DtU8 | compressionLevel | ) | [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().
| bool DtTcpMsgSocket::flush | ( | ) | [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().
| bool DtTcpMsgSocket::flushQueue | ( | ) | [protected, virtual] |
Attempts to send any queued messages.
Returns true if all queued messages were sent.
References myMsgQueue, and DtMsgSocket::mySocket.
Referenced by flush(), and sendData().
| bool DtTcpMsgSocket::getQueueStatus | ( | int & | percentFull | ) | const [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().
| DtInetTcpSocket * DtTcpMsgSocket::inetTcpSocket | ( | ) | [inline] |
Returns a pointer to the DtInetTcpSocket.
Referenced by DtTcpMsgSocketMgr::addSocket(), DtMessageFilter::addToSocketMap(), DtRtiAssistantServer::readAndProcess(), DtMessageFilter::removeFromSocketMap(), and DtTcpMsgSocketMgr::socketIter().
| bool DtTcpMsgSocket::isConnected | ( | ) | const [inline] |
Returns true if the socket is connected.
Referenced by DtInOutForwarderPort::addSocketUsingRoutesFile(), DtInOutForwarderPort::checkConnectionStatus(), DtPeerToPeerTcpSockMgr::connectToPeer(), DtInOutForwarderPort::connectToPeer(), DtTcpWwwSpyAdapter::connectToWebServer(), DtConnectionMgr::createAncillaryRelConns(), DtConnectionMgr::createRelConn(), DtTcpRtiConnectionMgr::establishConnection(), DtTcpWwwSpyAdapter::getNextMsg(), DtInOutForwarderPort::getNextMsg(), DtExtendedRtiMsgForwarder::getNextMsg(), DtRtiAssistantClient::isConnected(), DtRtiAssistantClient::makeSingleConnectionAttempt(), DtRtiAssistantClient::netRead(), DtTcpWwwSpyAdapter::postMsg(), DtPeerToPeerTcpSockMgr::processConnections(), DtTcpForwarder__vl__::readAndForward(), DtTcpRtiConnectionMgr::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().
| bool DtTcpMsgSocket::isConnectionInProgress | ( | ) | const [inline] |
Returns true if the socket is in the process of connecting.
Referenced by DtInOutForwarderPort::addSocketUsingRoutesFile(), DtPeerToPeerTcpSockMgr::connectToPeer(), DtInOutForwarderPort::connectToPeer(), and DtPeerToPeerTcpSockMgr::processConnections().
| DtU32 DtTcpMsgSocket::maxMsgSize | ( | ) | const [virtual] |
Gets the maximum message size.
References DtMsgSocket::mySocket.
| int DtTcpMsgSocket::maxQueuedMessages | ( | ) | const [virtual] |
Returns the maximum number of messages that can be queued.
A negative value indicates no limit is imposed.
References myMaxQueuedMessages.
| void DtTcpMsgSocket::openClientSocket | ( | const DtInetEndpoint & | dest, |
| DtU32 | flags = DtDefaultSockOpts, |
||
| DtU16 | localPort = 0, |
||
| DtInetDevice * | hostIf = NULL |
||
| ) | [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(), DtTcpWwwSpyAdapter::connectToWebServer(), DtConnectionMgr::createAncillaryRelConns(), DtConnectionMgr::createRelConn(), and DtRtiAssistantClient::makeSingleConnectionAttempt().
| void DtTcpMsgSocket::openServerSocket | ( | DtU16 | localPort, |
| DtU32 | flags = DtDefaultSockOpts, |
||
| DtInetDevice * | hostIf = NULL, |
||
| DtInetUtils::DtInetAddrFamily | family = DtInetUtils::DtInetAddrFamily_IPv4 |
||
| ) | [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.
| bool DtTcpMsgSocket::queueMessage | ( | caddr_t | msg, |
| size_t | msgSize | ||
| ) | [protected, virtual] |
Adds a message to the transmit queue. Returns true if successful.
References DtMsgSocket::myLastError, myMaxQueuedMessages, and myMsgQueue.
Referenced by sendData().
| int DtTcpMsgSocket::recvMessage | ( | caddr_t * | buffptr | ) | [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(), DtTcpWwwSpyAdapter::netRead(), DtTcpRtiConnectionMgr::netRead(), DtRtiAssistantClient::netRead(), DtRtiAssistantServer::netRead(), DtTcpForwarder__vl__::readAndForward(), DtFilteredTcpForwarder::readAndForward(), and recvMessageWithSrc().
| int DtTcpMsgSocket::recvMessageWithSrc | ( | caddr_t * | buffptr, |
| DtInetEndpoint & | src | ||
| ) | [virtual] |
Gets the next message from the stream of incoming data.
Implements DtMsgSocket.
References DtMsgSocket::mySocket, and recvMessage().
| void DtTcpMsgSocket::resizeTestPacket | ( | ) | [protected, virtual] |
Resizes the test packet used to test the connection.
References myBytesNeededForSize, DtMsgSocket::myHeaderReader, and myTestPacket.
Referenced by DtTcpMsgSocket().
| int DtTcpMsgSocket::sendData | ( | caddr_t | msg, |
| size_t | msgSize, | ||
| bool | deleteAfterSend | ||
| ) | [protected, virtual] |
Sends data on the socket, queues if it cannot be sent.
References flushQueue(), DtMsgSocket::myLastError, DtMsgSocket::mySocket, and queueMessage().
Referenced by flush(), and sendMessage().
| int DtTcpMsgSocket::sendMessage | ( | caddr_t | msg, |
| size_t | msgSize, | ||
| bool | deleteAfterSend, | ||
| const DtInetAddr & | destAddr = DtInetAddr::inaddrAny() |
||
| ) | [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 DtTcpRtiConnectionMgr::establishConnection(), DtTcpRtiConnectionMgr::postCommand(), DtTcpWwwSpyAdapter::postMsg(), 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().
| void DtTcpMsgSocket::setMaxQueuedMessages | ( | int | size | ) | [virtual] |
Sets the maximum number of messages that can be queued.
A negative value indicates no limit is imposed.
References myMaxQueuedMessages.
| void DtTcpMsgSocket::setNonBlocking | ( | bool | nonBlocking | ) | [virtual] |
Makes the socket non-blocking or blocking.
References DtMsgSocket::mySocket.
Referenced by DtTcpWwwSpyAdapter::connectToWebServer(), DtConnectionMgr::createAncillaryRelConns(), DtConnectionMgr::createRelConn(), and DtRtiAssistantClient::makeSingleConnectionAttempt().
| void DtTcpMsgSocket::setTcpNoDelay | ( | bool | enable | ) | [virtual] |
Changes the setting of TCP_NODELAY.
References DtMsgSocket::mySocket.
Referenced by DtTcpMsgSocketMgr::socketAdded().
| bool DtTcpMsgSocket::testConnectionStatus | ( | ) | [virtual] |
References myTestPacket, and sendMessage().
Referenced by DtInOutForwarderPort::checkConnectionStatus(), DtPeerToPeerTcpSockMgr::processConnections(), DtRtiAssistantClient::sendMsgAndWait(), DtInOutForwarderPort::socketAdditionCb(), DtTcpRtiConnectionMgr::testConnections(), DtRtiAssistantServer::testConnections(), DtRtiAssistantClient::testConnectionStatus(), and DtRtiAssistantClient::tick().
bool DtTcpMsgSocket::myBundlingEnabled [protected] |
Whether message bundling is enabled.
Referenced by bundleSize(), disableBundling(), enableBundling(), flush(), and sendMessage().
size_t DtTcpMsgSocket::myBytesNeededForSize [protected] |
The number of bytes needed to read the size from the message header.
Referenced by DtTcpMsgSocket(), recvMessage(), and resizeTestPacket().
bool DtTcpMsgSocket::myCompressionEnabled [protected] |
Whether message compression is enabled.
Referenced by compressionLevel(), disableCompression(), enableCompression(), and sendMessage().
int DtTcpMsgSocket::myMaxQueuedMessages [protected] |
The maximum size the send queue is allowed to reach.
Referenced by getQueueStatus(), maxQueuedMessages(), queueMessage(), and setMaxQueuedMessages().
DtMsgBundler DtTcpMsgSocket::myMsgBundler [protected] |
Bundler for outgoing messages.
Referenced by bundleSize(), enableBundling(), flush(), and sendMessage().
DtMsgCompressor DtTcpMsgSocket::myMsgCompressor [protected] |
Message compressor and uncompressor.
Referenced by compressionLevel(), enableCompression(), recvMessage(), and sendMessage().
std::list<DtQueuedMsg> DtTcpMsgSocket::myMsgQueue [protected] |
The queue of unsent messages.
Referenced by flush(), flushQueue(), getQueueStatus(), and queueMessage().
int DtTcpMsgSocket::myMutableOldQueueLevel [mutable, protected] |
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().
bool DtTcpMsgSocket::myNeedSize [protected] |
Whether we still need to receive the size field for the next/current message.
Referenced by recvMessage().
int DtTcpMsgSocket::myNumBytesReceived [protected] |
The number of bytes we have so far received for the current message.
Referenced by recvMessage().
int DtTcpMsgSocket::myNumBytesToWaitFor [protected] |
The number of bytes we are waiting for to complete the message.
Referenced by DtTcpMsgSocket(), and recvMessage().
DtInetBuffer DtTcpMsgSocket::myTestPacket [protected] |
The buffer to store test packets in.
Referenced by resizeTestPacket(), and testConnectionStatus().