MAK RTIspy API Documentation for HLA Evolved
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:

List of all members.

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())
 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.
void setFilterPort (int port)
 Sets the filter port.

Protected Member Functions

virtual int sendPacket (caddr_t msg, size_t msgSize, const DtInetAddr &destAddr=DtInetAddr::inaddrAny())
 Sends a single packet.
virtual int retrySendTo (caddr_t msg, size_t msgSize, const DtInetAddr &destAddr=DtInetAddr::inaddrAny())
 Retries sending a message which failed to send.
virtual int recv (caddr_t *buffptr, DtInetEndpoint *ep)
 Gets the next message from the incoming data.

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.

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.

Destructor.


Member Function Documentation

void DtUdpMsgSocket::disableBundling ( ) [virtual]

Disables message bundling.

Implements DtMsgSocket.

Reimplemented in DtSmSocket__rti__.

References myBundlingEnabled.

Disables message compression.

Implements DtMsgSocket.

Reimplemented in DtSmSocket__rti__.

References myCompressionEnabled.

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

Reimplemented in DtSmSocket__rti__.

References inetUdpSocket().

void DtUdpMsgSocket::enableBundling ( size_t  maxBundleSize) [virtual]
void DtUdpMsgSocket::enableCompression ( DtU8  compressionLevel) [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.

References DtMsgBundler::getBundle(), myBundlingEnabled, myDefaultMsgBundler, myMsgBundlers, DtMsgSocket::mySocket, and sendPacket().

Referenced by DtExtendedRtiMsgForwarder::flush(), and DtMulitcastDiscoveryMgr::requestAddress().

DtInetUdpSocket * DtUdpMsgSocket::inetUdpSocket ( ) [inline]

Returns a pointer to the DtInetUdpSocket.

Referenced by dropMulticastGroup(), joinMulticastGroup(), DtRtiAssistantPeer::netRead(), and setMcastTtlOption().

bool DtUdpMsgSocket::isOpen ( ) const [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__.

References inetUdpSocket().

Referenced by DtExtendedRtiMsgForwarder::listenToMulticastGroup().

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

Reimplemented in DtSmSocket__rti__.

References inetUdpSocket().

DtU32 DtUdpMsgSocket::maxMsgSize ( ) const [virtual]

Gets the maximum message size.

References DtMsgSocket::mySocket.

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__.

References myEndpoint, DtMsgSocket::myLastError, and DtMsgSocket::mySocket.

Referenced by DtRtiAssistantPeer::addSocketsForInterfaces(), DtConnectionMgr::createBestEffortConn(), DtMulitcastDiscoveryMgr::init(), DtExtendedRtiMsgForwarder::init(), and DtInOutForwarderPort::initializeConnections().

int DtUdpMsgSocket::recv ( caddr_t *  buffptr,
DtInetEndpoint *  ep 
) [protected, virtual]
int DtUdpMsgSocket::recvMessage ( caddr_t *  buffptr) [virtual]
int DtUdpMsgSocket::recvMessageWithSrc ( caddr_t *  buffptr,
DtInetEndpoint &  src 
) [virtual]

Gets the next message from the incoming data.

Implements DtMsgSocket.

References recv().

int DtUdpMsgSocket::retrySendTo ( caddr_t  msg,
size_t  msgSize,
const DtInetAddr &  destAddr = DtInetAddr::inaddrAny() 
) [protected, virtual]

Retries sending a message which failed to send.

References myEndpoint, myMaxSendRetries, mySendRetryPeriod, and DtMsgSocket::mySocket.

Referenced by sendPacket().

int DtUdpMsgSocket::sendMessage ( caddr_t  msg,
size_t  msgSize,
bool  deleteAfterSend,
const DtInetAddr &  destAddr = DtInetAddr::inaddrAny() 
) [virtual]
int DtUdpMsgSocket::sendPacket ( caddr_t  msg,
size_t  msgSize,
const DtInetAddr &  destAddr = DtInetAddr::inaddrAny() 
) [protected, virtual]

Sends a single packet.

References myEndpoint, DtMsgSocket::mySocket, and retrySendTo().

Referenced by flush(), and sendMessage().

void DtUdpMsgSocket::setFilterPort ( int  port) [inline]

Sets the filter port.

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

Referenced by DtExtendedRtiMsgForwarder::init().

bool DtUdpMsgSocket::setMcastTtlOption ( DtU32  ttl) [virtual]

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

Reimplemented in DtSmSocket__rti__.

References inetUdpSocket().

Referenced by DtConnectionMgr::createBestEffortConn(), DtMulitcastDiscoveryMgr::init(), and DtExtendedRtiMsgForwarder::init().

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

Enables/disables send retries on failure.

Reimplemented in DtSmSocket__rti__.

References myMaxSendRetries, and mySendRetryPeriod.

Referenced by DtConnectionMgr::createBestEffortConn(), DtMulitcastDiscoveryMgr::init(), and DtExtendedRtiMsgForwarder::init().


Member Data Documentation

Whether message bundling is enabled.

Referenced by disableBundling(), enableBundling(), flush(), and sendMessage().

Whether message compression is enabled.

Referenced by disableCompression(), enableCompression(), and sendMessage().

Message bundler for the default destination.

Also handles unbundling of all incoming data.

Referenced by enableBundling(), flush(), recv(), and sendMessage().

DtInetEndpoint DtUdpMsgSocket::myEndpoint [protected]

The current endpoint to send to.

Referenced by openSocket(), retrySendTo(), and sendPacket().

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

Referenced by recv().

DtInetEndpoint DtUdpMsgSocket::myLastSourceEndpoint [protected]

Source endpoint of last data received.

Referenced by recv().

size_t DtUdpMsgSocket::myMaxPacketSize [protected]

The maximum packet size.

unsigned int DtUdpMsgSocket::myMaxSendRetries [protected]

The maximum number of times to try resending.

Referenced by retrySendTo(), and setRetryOnSend().

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

Message bundlers for outgoing messages for each destination address.

Referenced by enableBundling(), flush(), and sendMessage().

Message compressor and uncompressor.

Referenced by enableCompression(), recv(), and sendMessage().

The wait period between send retries.

Referenced by retrySendTo(), and setRetryOnSend().


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

Document ID: Generated on Thu Jun 14 14:15:04 EDT 2012 from SVN revision 116116
Copyright © 2005-2012 VT MÄK Inc. All Rights Reserved (www.mak.com)