MAK RTIspy API Documentation for HLA 1.3
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
List of all members | Public Member Functions | Protected Member Functions | Protected Attributes
DtUdpMsgSocket Class Reference

The DtUdpMsgSocket class provides an address family independent UDP socket that handles RTI messages. More...

+ Inheritance diagram for DtUdpMsgSocket:
+ Collaboration diagram for DtUdpMsgSocket:

Public Member Functions

 DtUdpMsgSocket (DtBoost::shared_ptr< DtMsgHeaderReader > hdrReader, size_t maxPacketSize=DtDefaultMaxPacketSize)
 Constructor.
virtual ~DtUdpMsgSocket ()
 Destructor.
virtual void openSocket (const DtInetEndpoint &dest, DtU32 flags=DtDefaultSockOpts, DtU16 localPort=0, DtInetDevice *hostIf=NULL)
 Opens the socket if not already open.
virtual int sendMessage (caddr_t msg, size_t msgSize, bool deleteAfterSend, const DtInetAddr &destAddr=DtInetAddr::inaddrAny(), int port=0)
 Sends a message.
virtual bool flush ()
 Attempts to send any queued messages and bundled messages.
virtual int recvMessage (caddr_t *buffptr)
 Gets the next message from the incoming data.
virtual int recvMessageWithSrc (caddr_t *buffptr, DtInetEndpoint &src)
 Gets the next message from the incoming data.
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 bool joinMulticastGroup (const DtInetAddr &grpAddr, DtInetDevice *device=NULL)
 Join / drop subscription to multicast group.
virtual bool joinMulticastGroup (const DtInetEndpoint &grpEndpoint, DtInetDevice *device=NULL)
virtual bool dropMulticastGroup (const DtInetAddr &grpAddr, DtInetDevice *device=NULL)
virtual bool dropMulticastGroup (const DtInetEndpoint &grpEndpoint, DtInetDevice *device=NULL)
virtual bool setMcastTtlOption (DtU32 ttl)
 Change the default time-to-live on outbound multicast packets sent from this socket.
virtual void setRetryOnSend (unsigned int numRetries, double waitPeriod)
 Enables/disables send retries on failure.
virtual DtU32 maxMsgSize () const
 Gets the maximum message size.
virtual bool isOpen () const
 Returns true if the socket is open.
DtInetUdpSocket * inetUdpSocket ()
 Returns a pointer to the DtInetUdpSocket.
virtual void setFilterPort (int port)
 Sets the filter port. All messages sent from this port on this machine will be filtered.
- 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.
unsigned int descriptor () const
 Get's the socket file descriptor.
DtInetSocket * inetSocket ()
 Returns a pointer to the DtInetSocket.

Protected Member Functions

virtual int sendPacket (caddr_t msg, size_t msgSize, const DtInetAddr &destAddr=DtInetAddr::inaddrAny(), int port=0)
 Sends a single packet; handle retries if necessary.
virtual int doSendPacket (caddr_t msg, size_t msgSize, const DtInetAddr &destAddr=DtInetAddr::inaddrAny(), int port=0)
 Just do the send packet part dealing with destination and port.
virtual int retrySendTo (caddr_t msg, size_t msgSize, const DtInetAddr &destAddr=DtInetAddr::inaddrAny(), int port=0)
 Retry sending a message which failed to send.
virtual int recv (caddr_t *buffptr, DtInetEndpoint *ep)
 Gets the next message from the incoming data.
- Protected Member Functions inherited from DtMsgSocket
void expandRecvBuffer (size_t sizeNeeded)
 Expands the receive buffer to accommodate the given size message.

Protected Attributes

DtInetEndpoint myEndpoint
 The current endpoint to send to.
std::map< DtInetAddr,
DtMsgBundler * > 
myMsgBundlers
 Message bundlers for outgoing messages for each destination address.
DtMsgBundler myDefaultMsgBundler
 Message bundler for the default destination.
bool myBundlingEnabled
 Whether message bundling is enabled.
DtMsgCompressor myMsgCompressor
 Message compressor and uncompressor.
bool myCompressionEnabled
 Whether message compression is enabled.
DtInetEndpoint myLastSourceEndpoint
 Source endpoint of last data received.
size_t myMaxPacketSize
 The maximum packet size.
unsigned int myMaxSendRetries
 The maximum number of times to try resending.
double mySendRetryPeriod
 The wait period between send retries.
int myFilterPort
 All messages sent from this port on this machine will be filtered.
- 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.

Detailed Description

The DtUdpMsgSocket class provides an address family independent UDP socket that handles RTI messages.

Constructor & Destructor Documentation

DtUdpMsgSocket::DtUdpMsgSocket ( DtBoost::shared_ptr< DtMsgHeaderReader hdrReader,
size_t  maxPacketSize = DtDefaultMaxPacketSize 
)

Constructor.

Requires a header reader to extract information from message headers. Does NOT open the socket. A call to openSocket() is required.

virtual DtUdpMsgSocket::~DtUdpMsgSocket ( )
virtual

Destructor.

Member Function Documentation

virtual void DtUdpMsgSocket::disableBundling ( )
virtual

Disables message bundling.

Implements DtMsgSocket.

Reimplemented in DtSmSocket__rti__.

virtual void DtUdpMsgSocket::disableCompression ( )
virtual

Disables message compression.

Implements DtMsgSocket.

Reimplemented in DtSmSocket__rti__.

virtual int DtUdpMsgSocket::doSendPacket ( caddr_t  msg,
size_t  msgSize,
const DtInetAddr &  destAddr = DtInetAddr::inaddrAny(),
int  port = 0 
)
protectedvirtual

Just do the send packet part dealing with destination and port.

virtual bool DtUdpMsgSocket::dropMulticastGroup ( const DtInetAddr &  grpAddr,
DtInetDevice *  device = NULL 
)
virtual

Reimplemented in DtSmSocket__rti__.

virtual bool DtUdpMsgSocket::dropMulticastGroup ( const DtInetEndpoint &  grpEndpoint,
DtInetDevice *  device = NULL 
)
virtual

Reimplemented in DtSmSocket__rti__.

virtual void DtUdpMsgSocket::enableBundling ( size_t  maxBundleSize)
virtual

Enables message bundling and sets the maximum bundle size.

Implements DtMsgSocket.

Reimplemented in DtSmSocket__rti__.

virtual void DtUdpMsgSocket::enableCompression ( DtU8  compressionLevel)
virtual

Enables message compression and sets the compression level.

Implements DtMsgSocket.

Reimplemented in DtSmSocket__rti__.

virtual bool DtUdpMsgSocket::flush ( )
virtual

Attempts to send any queued messages and bundled messages.

Returns true if all queued and bundled messages were sent.

Implements DtMsgSocket.

Reimplemented in DtSmSocket__rti__, and DtRtiSmSocket.

Referenced by DtExtendedRtiMsgForwarder::flush().

DtInetUdpSocket * DtUdpMsgSocket::inetUdpSocket ( )
inline

Returns a pointer to the DtInetUdpSocket.

virtual bool DtUdpMsgSocket::isOpen ( ) const
virtual

Returns true if the socket is open.

Reimplemented in DtSmSocket__rti__.

Referenced by DtExtendedRtiMsgForwarder::flush().

virtual bool DtUdpMsgSocket::joinMulticastGroup ( const DtInetAddr &  grpAddr,
DtInetDevice *  device = NULL 
)
virtual

Join / drop subscription to multicast group.

Socket will join group identified by the multicast address in grpAddr or grpEndpoint. If an object is passed in the port value of the endpoint will be ignored and the socket will join from the same port the socket's local endpoint uses. If no interface is specified in the join it will join on the host's default multicast interface.

Reimplemented in DtSmSocket__rti__.

virtual bool DtUdpMsgSocket::joinMulticastGroup ( const DtInetEndpoint &  grpEndpoint,
DtInetDevice *  device = NULL 
)
virtual

Reimplemented in DtSmSocket__rti__.

virtual DtU32 DtUdpMsgSocket::maxMsgSize ( ) const
virtual

Gets the maximum message size.

virtual void DtUdpMsgSocket::openSocket ( const DtInetEndpoint &  dest,
DtU32  flags = DtDefaultSockOpts,
DtU16  localPort = 0,
DtInetDevice *  hostIf = NULL 
)
virtual

Opens the 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. If the destination endpoint specifies a multicast address the multicast group is joined automatically when the socket is opened and the group member- ship is dropped when the socket is closed. This ctor will not throw exceptions on failure. Check the socket status by calling state() to determine if the socket is ready.

Reimplemented in DtSmSocket__rti__.

virtual int DtUdpMsgSocket::recv ( caddr_t *  buffptr,
DtInetEndpoint *  ep 
)
protectedvirtual

Gets the next message from the incoming data.

Reimplemented in DtRtiSmSocket, and DtSmSocket__rti__.

virtual int DtUdpMsgSocket::recvMessage ( caddr_t *  buffptr)
virtual

Gets the next message from the incoming data.

Implements DtMsgSocket.

virtual int DtUdpMsgSocket::recvMessageWithSrc ( caddr_t *  buffptr,
DtInetEndpoint &  src 
)
virtual

Gets the next message from the incoming data.

Implements DtMsgSocket.

virtual int DtUdpMsgSocket::retrySendTo ( caddr_t  msg,
size_t  msgSize,
const DtInetAddr &  destAddr = DtInetAddr::inaddrAny(),
int  port = 0 
)
protectedvirtual

Retry sending a message which failed to send.

virtual int DtUdpMsgSocket::sendMessage ( caddr_t  msg,
size_t  msgSize,
bool  deleteAfterSend,
const DtInetAddr &  destAddr = DtInetAddr::inaddrAny(),
int  port = 0 
)
virtual

Sends a message.

Implements DtMsgSocket.

virtual int DtUdpMsgSocket::sendPacket ( caddr_t  msg,
size_t  msgSize,
const DtInetAddr &  destAddr = DtInetAddr::inaddrAny(),
int  port = 0 
)
protectedvirtual

Sends a single packet; handle retries if necessary.

virtual void DtUdpMsgSocket::setFilterPort ( int  port)
inlinevirtual

Sets the filter port. All messages sent from this port on this machine will be filtered.

virtual bool DtUdpMsgSocket::setMcastTtlOption ( DtU32  ttl)
virtual

Change the default time-to-live on outbound multicast packets sent from this socket.

Reimplemented in DtSmSocket__rti__.

virtual void DtUdpMsgSocket::setRetryOnSend ( unsigned int  numRetries,
double  waitPeriod 
)
virtual

Enables/disables send retries on failure.

Reimplemented in DtSmSocket__rti__.

Member Data Documentation

bool DtUdpMsgSocket::myBundlingEnabled
protected

Whether message bundling is enabled.

bool DtUdpMsgSocket::myCompressionEnabled
protected

Whether message compression is enabled.

DtMsgBundler DtUdpMsgSocket::myDefaultMsgBundler
protected

Message bundler for the default destination.

Also handles unbundling of all incoming data.

DtInetEndpoint DtUdpMsgSocket::myEndpoint
protected

The current endpoint to send to.

int DtUdpMsgSocket::myFilterPort
protected

All messages sent from this port on this machine will be filtered.

DtInetEndpoint DtUdpMsgSocket::myLastSourceEndpoint
protected

Source endpoint of last data received.

size_t DtUdpMsgSocket::myMaxPacketSize
protected

The maximum packet size.

unsigned int DtUdpMsgSocket::myMaxSendRetries
protected

The maximum number of times to try resending.

std::map<DtInetAddr, DtMsgBundler*> DtUdpMsgSocket::myMsgBundlers
protected

Message bundlers for outgoing messages for each destination address.

DtMsgCompressor DtUdpMsgSocket::myMsgCompressor
protected

Message compressor and uncompressor.

double DtUdpMsgSocket::mySendRetryPeriod
protected

The wait period between send retries.


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

Document ID: Generated on Fri Sep 27 00:57:56 EDT 2019 from SVN revision 201708
Copyright © 2005-2018 VT MÄK Inc. All Rights Reserved (www.mak.com)