![]() |
MAK RTIspy API Documentation for HLA 1.3
|
00001 /********************************************************************* 00002 ** Copyright (c) 2010 MaK Technologies, Inc. 00003 ** All rights reserved. 00004 *********************************************************************/ 00005 /********************************************************************* 00006 ** $RCSfile: udpMsgSocket.h,v $ $Revision: $ $State: Exp $ 00007 *********************************************************************/ 00008 00013 00014 #ifndef udpMsgSocket_H_ 00015 #define udpMsgSocket_H_ 00016 00017 #include "msgSocket.h" 00018 #include "msgBundler.h" 00019 #include "msgCompressor.h" 00020 00021 #include <vlutil/vlInetUdpSocket.h> 00022 00023 const size_t DtDefaultMaxPacketSize = 15000; 00024 00025 using namespace MAKRti; 00026 00030 class DT_DLL_RTIUTIL DtUdpMsgSocket : public DtMsgSocket 00031 { 00032 public: 00033 00037 DtUdpMsgSocket(DtBoost::shared_ptr<DtMsgHeaderReader> hdrReader, 00038 size_t maxPacketSize = DtDefaultMaxPacketSize); 00039 00041 virtual ~DtUdpMsgSocket(); 00042 00058 virtual void openSocket(const DtInetEndpoint& dest, 00059 DtU32 flags = DtDefaultSockOpts, DtU16 localPort = 0, 00060 DtInetDevice* hostIf = NULL); 00061 00063 virtual int sendMessage(caddr_t msg, size_t msgSize, bool deleteAfterSend, 00064 const DtInetAddr& destAddr = DtInetAddr::inaddrAny()); 00065 00068 virtual bool flush(); 00069 00071 virtual int recvMessage(caddr_t *buffptr); 00072 00074 virtual int recvMessageWithSrc(caddr_t *buffptr, DtInetEndpoint& src); 00075 00077 virtual void enableBundling(size_t maxBundleSize); 00078 00080 virtual void disableBundling(); 00081 00083 virtual void enableCompression(DtU8 compressionLevel); 00084 00086 virtual void disableCompression(); 00087 00094 virtual bool joinMulticastGroup( const DtInetAddr& grpAddr, 00095 DtInetDevice* device = NULL ); 00096 virtual bool joinMulticastGroup( const DtInetEndpoint& grpEndpoint, 00097 DtInetDevice* device = NULL ); 00098 virtual bool dropMulticastGroup( const DtInetAddr& grpAddr, 00099 DtInetDevice* device = NULL ); 00100 virtual bool dropMulticastGroup( const DtInetEndpoint& grpEndpoint, 00101 DtInetDevice* device = NULL ); 00102 00105 virtual bool setMcastTtlOption( DtU32 ttl ); 00106 00108 virtual void setRetryOnSend(unsigned int numRetries, double waitPeriod); 00109 00111 virtual DtU32 maxMsgSize() const; 00112 00114 virtual bool isOpen() const; 00115 00117 DtInetUdpSocket* inetUdpSocket(); 00118 00121 void setFilterPort(int port) { myFilterPort = port; } 00122 00123 protected: 00124 00126 virtual int sendPacket(caddr_t msg, size_t msgSize, 00127 const DtInetAddr& destAddr = DtInetAddr::inaddrAny()); 00128 00130 virtual int retrySendTo(caddr_t msg, size_t msgSize, 00131 const DtInetAddr& destAddr = DtInetAddr::inaddrAny()); 00132 00134 virtual int recv(caddr_t *buffptr, DtInetEndpoint* ep); 00135 00136 protected: 00137 00139 DtInetEndpoint myEndpoint; 00140 00142 std::map<DtInetAddr, DtMsgBundler*> myMsgBundlers; 00143 00146 DtMsgBundler myDefaultMsgBundler; 00147 00149 bool myBundlingEnabled; 00150 00152 DtMsgCompressor myMsgCompressor; 00153 00155 bool myCompressionEnabled; 00156 00158 DtInetEndpoint myLastSourceEndpoint; 00159 00161 size_t myMaxPacketSize; 00162 00164 unsigned int myMaxSendRetries; 00165 00167 double mySendRetryPeriod; 00168 00170 int myFilterPort; 00171 }; 00172 00173 00174 inline DtInetUdpSocket* DtUdpMsgSocket::inetUdpSocket() 00175 { 00176 return static_cast<DtInetUdpSocket*>(mySocket.get()); 00177 } 00178 00179 #endif //! udpMsgSocket_H_