![]() |
MAK RTIspy API Documentation for HLA 1.3
|
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 (std::shared_ptr< DtMsgHeaderReader > hdrReader, size_t recvBufferSize=20000, int maxQueuedMsgs=-1) | |
| Constructor. More... | |
| DtTcpMsgSocket (DtUniquePtr< MAKRti::DtInetTcpSocket > socket, std::shared_ptr< DtMsgHeaderReader > hdrReader, size_t recvBuffSize=20000, int maxQueuedMsgs=-1) | |
| Constructor which takes a pre-created MAKRti::DtInetTcpSocket pointer. More... | |
| virtual | ~DtTcpMsgSocket () |
| Destructor. More... | |
| virtual void | openServerSocket (MAKRti::DtU16 localPort, MAKRti::DtU32 flags=theDefaultSockOpts, MAKRti::DtInetDevice *hostIf=NULL, MAKRti::DtInetUtils::DtInetAddrFamily family=MAKRti::DtInetUtils::DtInetAddrFamily_IPv4) |
| Opens a server socket if not already open. More... | |
| virtual void | openClientSocket (const MAKRti::DtInetEndpoint &dest, MAKRti::DtU32 flags=theDefaultSockOpts, MAKRti::DtU16 localPort=0, MAKRti::DtInetDevice *hostIf=NULL) |
| Opens a client socket if not already open. More... | |
| virtual MAKRti::DtInetTcpSocket * | reconnect () |
| virtual void | replaceSocket (DtUniquePtr< MAKRti::DtInetTcpSocket > newSock) |
| virtual int | sendMessage (caddr_t msg, size_t msgSize, bool deleteAfterSend, const MAKRti::DtInetAddr &destAddr=MAKRti::DtInetAddr::inaddrAny(), int port=0) |
| Sends a message, queuing it up if the receiver's buffer is full. More... | |
| virtual bool | flush () |
| Attempts to send any queued messages and bundled messages. More... | |
| virtual int | recvMessage (caddr_t *buffptr) |
| Gets the next message from the stream of incoming data. More... | |
| virtual int | recvMessageWithSrc (caddr_t *buffptr, MAKRti::DtInetEndpoint &src) |
| Gets the next message from the stream of incoming data. 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 unsigned | bundleSize () const |
| Returns the bundle size, or 0 if bundling disabled. More... | |
| virtual void | enableCompression (MAKRti::DtU8 compressionLevel) |
| Enables message compression and sets the compression level. More... | |
| virtual void | disableCompression () |
| Disables message compression. More... | |
| virtual unsigned | compressionLevel () const |
| Returns the compression level, or 0 if compression disabled. More... | |
| virtual bool | testConnectionStatus () |
| virtual void | setMaxQueuedMessages (int size) |
| Sets the maximum number of messages that can be queued. More... | |
| virtual int | maxQueuedMessages () const |
| Returns the maximum number of messages that can be queued. More... | |
| virtual bool | getQueueStatus (int &percentFull) const |
| Gets the percentage full of the message queue. More... | |
| virtual void | setTcpNoDelay (bool enable) |
| Changes the setting of TCP_NODELAY. More... | |
| virtual void | setNonBlocking (bool nonBlocking) |
| Makes the socket non-blocking or blocking. More... | |
| virtual const MAKRti::DtInetEndpoint & | destination () const |
| Returns the destination endpoint of this socket. More... | |
| virtual MAKRti::DtU32 | maxMsgSize () const |
| Gets the maximum message size. More... | |
| MAKRti::DtInetTcpSocket * | inetTcpSocket () |
| Returns a pointer to the MAKRti::DtInetTcpSocket. More... | |
| bool | isConnected () const |
| Returns true if the socket is connected. More... | |
| bool | isConnectionInProgress () const |
| Returns true if the socket is in the process of connecting. More... | |
| MAKRti::DtString | getErrorString () const |
| virtual bool | isClient () const |
Public Member Functions inherited from DtMsgSocket | |
| DtMsgSocket (std::shared_ptr< DtMsgHeaderReader > hdrReader, size_t recvBuffSize) | |
| Constructor. More... | |
| DtMsgSocket (DtUniquePtr< MAKRti::DtInetSocket > socket, std::shared_ptr< DtMsgHeaderReader > hdrReader, size_t recvBuffSize) | |
| Constructor which takes a pre-created MAKRti::DtInetSocket pointer. More... | |
| virtual | ~DtMsgSocket () |
| Destructor. More... | |
| virtual bool | closeSocket () |
| Close a socket. Returns true on successful close or false on failure. More... | |
| virtual MAKRti::DtInetSockState | state () const |
| Returns the state of the socket. More... | |
| void | printStateToStream (MAKRti::DtOutputStream &stream) const |
| prints state to stream More... | |
| const MAKRti::DtString & | lastError () const |
| Returns a description of the last error. More... | |
| const MAKRti::DtInetEndpoint & | localEndpoint () const |
| Gets the local endpoint for the socket. More... | |
| void | setSendBufferSize (MAKRti::DtU32 size) |
| Sets the socket send buffer size. More... | |
| void | setRecvBufferSize (MAKRti::DtU32 size) |
| Sets the socket receive buffer size. More... | |
| MAKRti::DtU32 | maxSendMsgSize () const |
| Gets the maximum socket send size. More... | |
| unsigned int | descriptor () const |
| Get's the socket file descriptor. More... | |
| MAKRti::DtInetSocket * | inetSocket () |
| Returns a pointer to the MAKRti::DtInetSocket. More... | |
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. More... | |
| virtual bool | flushQueue () |
| Attempts to send any queued messages. More... | |
| virtual bool | queueMessage (caddr_t msg, size_t msgSize) |
| Adds a message to the transmit queue. Returns true if successful. More... | |
| virtual void | resizeTestPacket () |
| Resizes the test packet used to test the connection. More... | |
Protected Member Functions inherited from DtMsgSocket | |
| void | expandRecvBuffer (size_t sizeNeeded) |
| Expands the receive buffer to accommodate the given size message. More... | |
Protected Attributes | |
| bool | myNeedSize |
| Whether we still need to receive the size field for the next/current message. More... | |
| size_t | myNumBytesToWaitFor |
| The number of bytes we are waiting for to complete the message. More... | |
| int | myNumBytesReceived |
| The number of bytes we have so far received for the current message. More... | |
| MAKRti::DtInetBuffer | myTestPacket |
| The buffer to store test packets in. More... | |
| std::list< DtQueuedMsg > | myMsgQueue |
| The queue of unsent messages. More... | |
| DtMsgBundler | myMsgBundler |
| Bundler for outgoing messages. More... | |
| bool | myBundlingEnabled |
| Whether message bundling is enabled. More... | |
| DtMsgCompressor | myMsgCompressor |
| Message compressor and uncompressor. More... | |
| bool | myCompressionEnabled |
| Whether message compression is enabled. More... | |
| int | myMaxQueuedMessages |
| The maximum size the send queue is allowed to reach. More... | |
| int | myMutableOldQueueLevel |
| The queue level the last time the user was notified of queue state. More... | |
| size_t | myBytesNeededForSize |
| The number of bytes needed to read the size from the message header. More... | |
| bool | myIsClient |
| MAKRti::DtInetEndpoint | myClientDestination |
| MAKRti::DtU32 | myClientFlags |
| MAKRti::DtU16 | myClientLocalPort |
| DtUniquePtr< MAKRti::DtInetDevice > | myClientHostIf |
Protected Attributes inherited from DtMsgSocket | |
| DtUniquePtr< MAKRti::DtInetSocket > | mySocket |
| The socket. More... | |
| MAKRti::DtInetBuffer | myRecvBuffer |
| The buffer to store received data in. More... | |
| MAKRti::DtString | myLastError |
| Description of last error. More... | |
| std::shared_ptr < DtMsgHeaderReader > | myHeaderReader |
| Reads data from message header. More... | |
Static Protected Attributes | |
| static const MAKRti::DtU32 | theDefaultSockOpts |
The DtTcpMsgSocket class provides an address family independent TCP socket that handles RTI messages.
| DtTcpMsgSocket::DtTcpMsgSocket | ( | std::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.
| DtTcpMsgSocket::DtTcpMsgSocket | ( | DtUniquePtr< MAKRti::DtInetTcpSocket > | socket, |
| std::shared_ptr< DtMsgHeaderReader > | hdrReader, | ||
| size_t | recvBuffSize = 20000, |
||
| int | maxQueuedMsgs = -1 |
||
| ) |
Constructor which takes a pre-created MAKRti::DtInetTcpSocket pointer.
Gives ownership and responsibility of the socket to the DtTcpMsgSocket object.
|
virtual |
Destructor.
|
virtual |
Returns the bundle size, or 0 if bundling disabled.
|
virtual |
Returns the compression level, or 0 if compression disabled.
|
virtual |
Returns the destination endpoint of this socket.
|
virtual |
Disables message bundling.
Implements DtMsgSocket.
|
virtual |
Disables message compression.
Implements DtMsgSocket.
|
virtual |
Enables message bundling and sets the maximum bundle size.
Implements DtMsgSocket.
|
virtual |
Enables message compression and sets the compression level.
Implements DtMsgSocket.
|
virtual |
Attempts to send any queued messages and bundled messages.
Returns true if all queued and bundled messages were sent.
Implements DtMsgSocket.
|
protectedvirtual |
Attempts to send any queued messages.
Returns true if all queued messages were sent.
| MAKRti::DtString DtTcpMsgSocket::getErrorString | ( | ) | 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.
|
inline |
Returns a pointer to the MAKRti::DtInetTcpSocket.
References DtMsgSocket::mySocket.
Referenced by DtMessageFilter::addToSocketMap(), DtMessageFilter::removeFromSocketMap(), and DtTcpMsgSocketMgr::socketIter().
|
virtual |
|
inline |
Returns true if the socket is connected.
|
inline |
Returns true if the socket is in the process of connecting.
|
virtual |
Gets the maximum message size.
|
virtual |
Returns the maximum number of messages that can be queued.
A negative value indicates no limit is imposed.
|
virtual |
Opens a client socket if not already open.
Takes a MAKRti::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.
|
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.
|
protectedvirtual |
Adds a message to the transmit queue. Returns true if successful.
|
virtual |
|
virtual |
Gets the next message from the stream of incoming data.
Implements DtMsgSocket.
|
virtual |
Gets the next message from the stream of incoming data.
Implements DtMsgSocket.
|
virtual |
|
protectedvirtual |
Resizes the test packet used to test the connection.
|
protectedvirtual |
Sends data on the socket, queues if it cannot be sent.
|
virtual |
Sends a message, queuing it up if the receiver's buffer is full.
destAddr is ignored.
Implements DtMsgSocket.
|
virtual |
Sets the maximum number of messages that can be queued.
A negative value indicates no limit is imposed.
|
virtual |
Makes the socket non-blocking or blocking.
|
virtual |
Changes the setting of TCP_NODELAY.
|
virtual |
|
protected |
Whether message bundling is enabled.
|
protected |
The number of bytes needed to read the size from the message header.
|
protected |
|
protected |
|
protected |
|
protected |
|
protected |
Whether message compression is enabled.
|
protected |
|
protected |
The maximum size the send queue is allowed to reach.
|
protected |
Bundler for outgoing messages.
|
protected |
Message compressor and uncompressor.
|
protected |
The queue of unsent messages.
|
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.
|
protected |
Whether we still need to receive the size field for the next/current message.
|
protected |
The number of bytes we have so far received for the current message.
|
protected |
The number of bytes we are waiting for to complete the message.
|
protected |
The buffer to store test packets in.
|
staticprotected |