VR-Link API Documentation for DIS
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
vlInetUdpSocket.h
Go to the documentation of this file.
1 /*********************************************************************
2 ** Copyright (c) 1992-2010 VT MAK
3 ** All rights reserved.
4 *********************************************************************/
10 #pragma once
11 
12 #include <vlutil/vlInetSocket.h>
13 
14 #ifdef DtUSE_UTILITIES_NAMESPACE
15 namespace DtUSE_UTILITIES_NAMESPACE
16 {
17 #endif
18 
19 class DtInetUdpSockPimpl;
20 
24 {
25 public:
28 
52  DtInetUdpSocket( const DtInetEndpoint& dest, DtU16 localPort = 0,
53  DtInetDevice* hostIf = NULL, DtU32 flags = DtDefaultSockOpts,
54  bool immediateOpen = true );
55 
57  virtual ~DtInetUdpSocket();
58 
71  virtual bool setDestination( const DtInetEndpoint& dest );
72 
76  virtual bool openSocket();
77 
81  virtual bool closeSocket();
82 
93  virtual bool bindToDevice( const DtInetDevice* hostIf = NULL );
94 
110  virtual bool connectToDestination();
111 
114  virtual bool disconnect();
115 
126  virtual int send( caddr_t packet, size_t size, DtU32 flags = 0 );
127  virtual int sendTo( caddr_t packet, size_t size,
128  DtInetEndpoint& dest, DtU32 flags = 0 );
129 
130  virtual int sendChain( DtInetBufferChain& packets, DtU32 flags = 0 );
131  virtual int sendChainTo( DtInetBufferChain& packets,
132  DtInetEndpoint& dest, DtU32 flags = 0 );
134 
145 
151  virtual DtInetSockRcvStatus recv( caddr_t buff, size_t buffSize,
152  DtU32 flags = 0 );
153 
162  virtual DtInetSockRcvStatus recvToChain( DtInetBufferChain& packets,
163  DtU32 flags = 0 );
164 
167  virtual DtInetSockRcvStatus recvFrom( caddr_t buff, size_t buffSize,
168  DtInetEndpoint& src,
169  DtU32 flags = 0 );
170  virtual DtInetSockRcvStatus recvToChainFrom( DtInetBufferChain& packets,
171  DtInetEndpoint& src,
172  DtU32 flags = 0 );
174 
177  virtual bool isOk();
178 
180  virtual int descriptor() const;
181 
184  virtual bool setSocket( const DtInetEndpoint& dest, DtU16 localPort = 0,
185  DtInetDevice* hostIf = NULL,
186  DtU32 flags = DtDefaultSockOpts );
187 
192  virtual bool setNonBlockingOption( bool onOrOff );
193  virtual bool setSendBufferSize( DtU32 size );
194  virtual bool setReceiveBufferSize( DtU32 size );
195  virtual bool setBroadcastOption( bool onOrOff );
196  virtual bool setReuseAddressOption( bool onOrOff );
197  virtual bool setDoNotRouteOption( bool onOrOff );
198  virtual bool setSendLowWatermark( DtU32 size );
199  virtual bool setReceiveLowWatermark( DtU32 size );
200  virtual bool setMcastDevice( const DtInetAddr& devAddr );
201  virtual bool setMcastDevice( DtInetDevice* hostIf );
202 
203  virtual DtU32 getSendBufferSize();
204  virtual DtU32 getReceiveBufferSize();
205  virtual DtU32 getBytesAvailable();
206  virtual bool getBroadcastOption();
207  virtual bool getReuseAddressOption();
208  virtual bool getDoNotRouteOption();
209  virtual DtU32 getSendLowWatermark();
210  virtual DtU32 getReceiveLowWatermark();
212 
221  virtual bool joinMulticastGroup( const DtInetAddr& grpAddr,
222  DtInetDevice* device = NULL );
223  virtual bool joinMulticastGroup( const DtInetEndpoint& grpEndpoint,
224  DtInetDevice* device = NULL );
225  virtual bool dropMulticastGroup( const DtInetAddr& grpAddr,
226  DtInetDevice* device = NULL );
227  virtual bool dropMulticastGroup( const DtInetEndpoint& grpEndpoint,
228  DtInetDevice* device = NULL );
231  virtual bool setMcastTtlOption( DtU32 ttl );
233 
236  virtual void* udpSocket();
237 
242  virtual void* secondUdpSocket();
243 
244 protected:
245 
246 private:
248  DtInetUdpSocket( const DtInetUdpSocket& orig );
249 
251  DtInetUdpSocket& operator=(const DtInetUdpSocket& orig);
252 
254  friend class DtInetUdpSockPimpl;
255  DtInetUdpSockPimpl* myAsyncPimpl;
256 
257 protected:
258  void* myIoService;
259  void* myUdpSocket;
260  //A second socket is only opened in the case that we're running linux AND
261  //we want to bind a socket to a specific device address while using broadcast
262  //This isn't possible with one boost socket, so we make a second just to listen for broadcast messages.
264 
267  // Since DtInetAddr can be either an IPv4 or IPv6 address the use of a
268  // std::map would be problematic since there's no easy way to compare
269  // addresses without defining a predicate functor.
270  typedef std::pair<DtInetAddr, DtInetAddr> DtInetMcastGroupIntfcBinding;
271  typedef std::vector<DtInetMcastGroupIntfcBinding> DtInetMcastGroupBindings;
273 
274 };
275 // end of class DtInetUdpSocket
276 
277 #ifdef DtUSE_UTILITIES_NAMESPACE
278 }
279 #endif
280 
281 
282 

Document ID: Generated on Wed Jan 7 13:31:29 EST 2015 from SVN revision 149162
Copyright © 2005-2014 VT MÄK. All Rights Reserved (www.mak.com)