![]() |
VR-Link API Documentation for HLA 1516
|
00001 /********************************************************************* 00002 ** Copyright (c) 1992-2010 VT MAK 00003 ** All rights reserved. 00004 *********************************************************************/ 00010 #pragma once 00011 00012 #include <vlutil/vlInetSocket.h> 00013 00014 #ifdef DtUSE_UTILITIES_NAMESPACE 00015 namespace DtUSE_UTILITIES_NAMESPACE 00016 { 00017 #endif 00018 00019 class DtInetUdpSockPimpl; 00020 00023 class DT_DLL_VLUTIL DtInetUdpSocket : public DtInetSocket 00024 { 00025 public: 00027 DtInetUdpSocket(); 00028 00052 DtInetUdpSocket( const DtInetEndpoint& dest, DtU16 localPort = 0, 00053 DtInetDevice* hostIf = NULL, DtU32 flags = DtDefaultSockOpts, 00054 bool immediateOpen = true ); 00055 00057 virtual ~DtInetUdpSocket(); 00058 00071 virtual bool setDestination( const DtInetEndpoint& dest ); 00072 00076 virtual bool openSocket(); 00077 00081 virtual bool closeSocket(); 00082 00093 virtual bool bindToDevice( const DtInetDevice* hostIf = NULL ); 00094 00110 virtual bool connectToDestination(); 00111 00114 virtual bool disconnect(); 00115 00126 virtual int send( caddr_t packet, size_t size, DtU32 flags = 0 ); 00127 virtual int sendTo( caddr_t packet, size_t size, 00128 DtInetEndpoint& dest, DtU32 flags = 0 ); 00129 00130 virtual int sendChain( DtInetBufferChain& packets, DtU32 flags = 0 ); 00131 virtual int sendChainTo( DtInetBufferChain& packets, 00132 DtInetEndpoint& dest, DtU32 flags = 0 ); 00134 00145 00151 virtual DtInetSockRcvStatus recv( caddr_t buff, size_t buffSize, 00152 DtU32 flags = 0 ); 00153 00162 virtual DtInetSockRcvStatus recvToChain( DtInetBufferChain& packets, 00163 DtU32 flags = 0 ); 00164 00167 virtual DtInetSockRcvStatus recvFrom( caddr_t buff, size_t buffSize, 00168 DtInetEndpoint& src, 00169 DtU32 flags = 0 ); 00170 virtual DtInetSockRcvStatus recvToChainFrom( DtInetBufferChain& packets, 00171 DtInetEndpoint& src, 00172 DtU32 flags = 0 ); 00174 00177 virtual bool isOk(); 00178 00180 virtual int descriptor() const; 00181 00184 virtual bool setSocket( const DtInetEndpoint& dest, DtU16 localPort = 0, 00185 DtInetDevice* hostIf = NULL, 00186 DtU32 flags = DtDefaultSockOpts ); 00187 00192 virtual bool setNonBlockingOption( bool onOrOff ); 00193 virtual bool setSendBufferSize( DtU32 size ); 00194 virtual bool setReceiveBufferSize( DtU32 size ); 00195 virtual bool setBroadcastOption( bool onOrOff ); 00196 virtual bool setReuseAddressOption( bool onOrOff ); 00197 virtual bool setDoNotRouteOption( bool onOrOff ); 00198 virtual bool setSendLowWatermark( DtU32 size ); 00199 virtual bool setReceiveLowWatermark( DtU32 size ); 00200 virtual bool setMcastDevice( const DtInetAddr& devAddr ); 00201 virtual bool setMcastDevice( DtInetDevice* hostIf ); 00202 00203 virtual DtU32 getSendBufferSize(); 00204 virtual DtU32 getReceiveBufferSize(); 00205 virtual DtU32 getBytesAvailable(); 00206 virtual bool getBroadcastOption(); 00207 virtual bool getReuseAddressOption(); 00208 virtual bool getDoNotRouteOption(); 00209 virtual DtU32 getSendLowWatermark(); 00210 virtual DtU32 getReceiveLowWatermark(); 00212 00221 virtual bool joinMulticastGroup( const DtInetAddr& grpAddr, 00222 DtInetDevice* device = NULL ); 00223 virtual bool joinMulticastGroup( const DtInetEndpoint& grpEndpoint, 00224 DtInetDevice* device = NULL ); 00225 virtual bool dropMulticastGroup( const DtInetAddr& grpAddr, 00226 DtInetDevice* device = NULL ); 00227 virtual bool dropMulticastGroup( const DtInetEndpoint& grpEndpoint, 00228 DtInetDevice* device = NULL ); 00231 virtual bool setMcastTtlOption( DtU32 ttl ); 00233 00236 virtual void* udpSocket(); 00237 00238 protected: 00239 00240 private: 00242 DtInetUdpSocket( const DtInetUdpSocket& orig ); 00243 00245 DtInetUdpSocket& operator=(const DtInetUdpSocket& orig); 00246 00248 friend class DtInetUdpSockPimpl; 00249 DtInetUdpSockPimpl* myAsyncPimpl; 00250 00251 protected: 00252 void* myIoService; 00253 void* myUdpSocket; 00254 00257 // Since DtInetAddr can be either an IPv4 or IPv6 address the use of a 00258 // std::map would be problematic since there's no easy way to compare 00259 // addresses without defining a predicate functor. 00260 typedef std::pair<DtInetAddr, DtInetAddr> DtInetMcastGroupIntfcBinding; 00261 typedef std::vector<DtInetMcastGroupIntfcBinding> DtInetMcastGroupBindings; 00262 DtInetMcastGroupBindings myMcastGroups; 00263 00264 }; 00265 // end of class DtInetUdpSocket 00266 00267 #ifdef DtUSE_UTILITIES_NAMESPACE 00268 } 00269 #endif 00270 00271 00272