MAK RTIspy API Documentation for HLA Evolved
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
udpMsgSocket.h
Go to the documentation of this file.
1 /*********************************************************************
2 ** Copyright (c) 2010 MaK Technologies, Inc.
3 ** All rights reserved.
4 *********************************************************************/
5 /*********************************************************************
6 ** $RCSfile: udpMsgSocket.h,v $ $Revision: $ $State: Exp $
7 *********************************************************************/
8 
12 
13 #pragma once
14 
15 #include "msgSocket.h"
16 #include "msgBundler.h"
17 #include "msgCompressor.h"
18 
19 #include <vlutil/vlInetUdpSocket.h>
20 
21 const size_t DtDefaultMaxPacketSize = 15000;
22 
27 {
28 public:
29 
33  DtUdpMsgSocket(std::shared_ptr<DtMsgHeaderReader> hdrReader,
34  size_t maxPacketSize = DtDefaultMaxPacketSize);
35 
37  virtual ~DtUdpMsgSocket();
38 
54  virtual void openSocket(const MAKRti::DtInetEndpoint& dest,
55  MAKRti::DtU32 flags = theDefaultSockOpts, MAKRti::DtU16 localPort = 0,
56  MAKRti::DtInetDevice* hostIf = NULL);
57 
59  virtual int sendMessage(caddr_t msg, size_t msgSize, bool deleteAfterSend,
60  const MAKRti::DtInetAddr& destAddr = MAKRti::DtInetAddr::inaddrAny(), int port = 0);
61 
64  virtual bool flush();
65 
67  virtual int recvMessage(caddr_t *buffptr);
68 
70  virtual int recvMessageWithSrc(caddr_t *buffptr, MAKRti::DtInetEndpoint& src);
71 
73  virtual void enableBundling(size_t maxBundleSize);
74 
76  virtual void disableBundling();
77 
79  virtual void enableCompression(MAKRti::DtU8 compressionLevel);
80 
82  virtual void disableCompression();
83 
90  virtual bool joinMulticastGroup( const MAKRti::DtInetAddr& grpAddr,
91  MAKRti::DtInetDevice* device = NULL );
92  virtual bool joinMulticastGroup( const MAKRti::DtInetEndpoint& grpEndpoint,
93  MAKRti::DtInetDevice* device = NULL );
94  virtual bool dropMulticastGroup( const MAKRti::DtInetAddr& grpAddr,
95  MAKRti::DtInetDevice* device = NULL );
96  virtual bool dropMulticastGroup( const MAKRti::DtInetEndpoint& grpEndpoint,
97  MAKRti::DtInetDevice* device = NULL );
98 
101  virtual bool setMcastTtlOption( MAKRti::DtU32 ttl );
102 
104  virtual void setRetryOnSend(unsigned int numRetries, double waitPeriod);
105 
107  virtual MAKRti::DtU32 maxMsgSize() const;
108 
110  virtual bool isOpen() const;
111 
113  MAKRti::DtInetUdpSocket* inetUdpSocket();
114 
116  virtual void setFilterPort(int port) { myFilterPort = port; }
117 
118 protected:
119 
121  virtual int sendPacket(caddr_t msg, size_t msgSize,
122  const MAKRti::DtInetAddr& destAddr = MAKRti::DtInetAddr::inaddrAny(),
123  int port = 0);
124 
126  virtual int doSendPacket(caddr_t msg, size_t msgSize,
127  const MAKRti::DtInetAddr& destAddr = MAKRti::DtInetAddr::inaddrAny(),
128  int port = 0);
129 
131  virtual int retrySendTo(caddr_t msg, size_t msgSize,
132  const MAKRti::DtInetAddr& destAddr = MAKRti::DtInetAddr::inaddrAny(),
133  int port = 0);
134 
136  virtual int recv(caddr_t *buffptr, MAKRti::DtInetEndpoint* ep);
137 
138 protected:
139 
141  MAKRti::DtInetEndpoint myEndpoint;
142 
144  std::map<MAKRti::DtInetAddr, DtMsgBundler*> myMsgBundlers;
145 
149 
152 
155 
158 
160  MAKRti::DtInetEndpoint myLastSourceEndpoint;
161 
164 
166  unsigned int myMaxSendRetries;
167 
170 
173 
174  static const MAKRti::DtU32 theDefaultSockOpts;
175 
176 };
177 
178 
179 inline MAKRti::DtInetUdpSocket* DtUdpMsgSocket::inetUdpSocket()
180 {
181  return static_cast<MAKRti::DtInetUdpSocket*>(mySocket.get());
182 }
std::map< MAKRti::DtInetAddr, DtMsgBundler * > myMsgBundlers
Message bundlers for outgoing messages for each destination address.
Definition: udpMsgSocket.h:144
MAKRti::DtInetEndpoint myEndpoint
The current endpoint to send to.
Definition: udpMsgSocket.h:141
bool myCompressionEnabled
Whether message compression is enabled.
Definition: udpMsgSocket.h:157
virtual void enableCompression(MAKRti::DtU8 compressionLevel)=0
Enables message compression and sets the compression level.
bool myBundlingEnabled
Whether message bundling is enabled.
Definition: udpMsgSocket.h:151
size_t myMaxPacketSize
The maximum packet size.
Definition: udpMsgSocket.h:163
This file contains the declaration of the DtMsgCompressor class.
MAKRti::DtInetUdpSocket * inetUdpSocket()
Returns a pointer to the MAKRti::DtInetUdpSocket.
Definition: udpMsgSocket.h:179
virtual int recvMessage(caddr_t *buffptr)=0
Gets the next message from the incoming data.
double mySendRetryPeriod
The wait period between send retries.
Definition: udpMsgSocket.h:169
unsigned int myMaxSendRetries
The maximum number of times to try resending.
Definition: udpMsgSocket.h:166
The DtMsgCompressor class provides a means for compressing and uncompressing messages.
Definition: msgCompressor.h:31
virtual void setFilterPort(int port)
Sets the filter port. All messages sent from this port on this machine will be filtered.
Definition: udpMsgSocket.h:116
This file contains the declaration of the DtMsgSocket base class.
virtual int sendMessage(caddr_t msg, size_t msgSize, bool deleteAfterSend, const MAKRti::DtInetAddr &destAddr=MAKRti::DtInetAddr::inaddrAny(), int port=0)=0
Sends a message.
MAKRti::DtInetEndpoint myLastSourceEndpoint
Source endpoint of last data received.
Definition: udpMsgSocket.h:160
const size_t DtDefaultMaxPacketSize
Definition: udpMsgSocket.h:21
The DtMsgBundler class provides a means for bundling and unbundling messages.
Definition: msgBundler.h:27
This file contains the declaration of the DtMsgBundler class.
virtual void disableBundling()=0
Disables message bundling.
The DtMsgSocket provides a wrapper around the MAKRti::DtInetSocket class to operate on messages rathe...
Definition: msgSocket.h:28
DtUniquePtr< MAKRti::DtInetSocket > mySocket
The socket.
Definition: msgSocket.h:116
virtual bool flush()=0
Attempts to send any queued messages and bundled messages.
int myFilterPort
All messages sent from this port on this machine will be filtered.
Definition: udpMsgSocket.h:172
virtual int recvMessageWithSrc(caddr_t *buffptr, MAKRti::DtInetEndpoint &src)=0
Gets the next message from the stream of incoming data and sets the source of the message...
DtMsgBundler myDefaultMsgBundler
Message bundler for the default destination.
Definition: udpMsgSocket.h:148
virtual void enableBundling(size_t maxBundleSize)=0
Enables message bundling and sets the maximum bundle size.
virtual void disableCompression()=0
Disables message compression.
#define DT_DLL_RTIUTIL
Definition: rtiMsConfig.h:160
The DtUdpMsgSocket class provides an address family independent UDP socket that handles RTI messages...
Definition: udpMsgSocket.h:26
DtMsgCompressor myMsgCompressor
Message compressor and uncompressor.
Definition: udpMsgSocket.h:154
static const MAKRti::DtU32 theDefaultSockOpts
Definition: udpMsgSocket.h:174

Document ID: Generated on Sun Jul 20 16:15:30 EDT 2025 from SVN revision 277985
Copyright © 2005-2025 MAK Technologies Inc. All Rights Reserved (www.mak.com)