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())
 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.
- 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())
 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 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.

DtUdpMsgSocket::~DtUdpMsgSocket ( )
virtual

Destructor.

Member Function Documentation

void DtUdpMsgSocket::disableBundling ( )
virtual

Disables message bundling.

Implements DtMsgSocket.

Reimplemented in DtSmSocket__rti__.

References myBundlingEnabled.

void DtUdpMsgSocket::disableCompression ( )
virtual

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 
)
protectedvirtual
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() 
)
protectedvirtual

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() 
)
protectedvirtual

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 DtRtiAssistantPeer::addSocketsForInterfaces(), 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

bool DtUdpMsgSocket::myBundlingEnabled
protected

Whether message bundling is enabled.

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

bool DtUdpMsgSocket::myCompressionEnabled
protected

Whether message compression is enabled.

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

DtMsgBundler DtUdpMsgSocket::myDefaultMsgBundler
protected

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().

int DtUdpMsgSocket::myFilterPort
protected

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().

DtMsgCompressor DtUdpMsgSocket::myMsgCompressor
protected

Message compressor and uncompressor.

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

double DtUdpMsgSocket::mySendRetryPeriod
protected

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 Wed Mar 11 20:26:49 EDT 2015 from SVN revision 150939
Copyright © 2005-2015 VT MÄK Inc. All Rights Reserved (www.mak.com)