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) 2015 VT MAK
3  * All rights reserved.
4  ****************************************************************************/
5 
9 
10 #pragma once
11 
12 #include <vlutil/vlInetSocket.h>
13 
14 
15 #ifdef DtUSE_UTILITIES_NAMESPACE
16 namespace DtUSE_UTILITIES_NAMESPACE
17 {
18 #endif
19 
20 class DtInetUdpSockPimpl;
21 
25 {
26 public:
29 
53  DtInetUdpSocket( const DtInetEndpoint& dest, DtU16 localPort = 0,
54  DtInetDevice* hostIf = NULL, DtU32 flags = DtDefaultSockOpts,
55  bool immediateOpen = true );
56 
58  virtual ~DtInetUdpSocket();
59 
72  virtual bool setDestination( const DtInetEndpoint& dest );
73 
77  virtual bool openSocket();
78 
82  virtual bool closeSocket();
83 
94  virtual bool bindToDevice( const DtInetDevice* hostIf = NULL );
95 
111  virtual bool connectToDestination();
112 
115  virtual bool disconnect();
116 
127  virtual int send( caddr_t packet, size_t size, DtU32 flags = 0 );
128  virtual int sendTo( caddr_t packet, size_t size,
129  DtInetEndpoint& dest, DtU32 flags = 0 );
130 
131  virtual int sendChain( DtInetBufferChain& packets, DtU32 flags = 0 );
132  virtual int sendChainTo( DtInetBufferChain& packets,
133  DtInetEndpoint& dest, DtU32 flags = 0 );
135 
146 
152  virtual DtInetSockRcvStatus recv( caddr_t buff, size_t buffSize,
153  DtU32 flags = 0 );
154 
163  virtual DtInetSockRcvStatus recvToChain( DtInetBufferChain& packets,
164  DtU32 flags = 0 );
165 
168  virtual DtInetSockRcvStatus recvFrom( caddr_t buff, size_t buffSize,
169  DtInetEndpoint& src,
170  DtU32 flags = 0 );
171  virtual DtInetSockRcvStatus recvToChainFrom( DtInetBufferChain& packets,
172  DtInetEndpoint& src,
173  DtU32 flags = 0 );
175 
178  virtual bool isOk();
179 
181  virtual unsigned descriptor() const;
182 
185  virtual bool setSocket( const DtInetEndpoint& dest, DtU16 localPort = 0,
186  DtInetDevice* hostIf = NULL,
187  DtU32 flags = DtDefaultSockOpts );
188 
193  virtual bool setNonBlockingOption( bool onOrOff );
194  virtual bool setSendBufferSize( DtU32 size );
195  virtual bool setReceiveBufferSize( DtU32 size );
196  virtual bool setBroadcastOption( bool onOrOff );
197  virtual bool setReuseAddressOption( bool onOrOff );
198  virtual bool setDoNotRouteOption( bool onOrOff );
199  virtual bool setSendLowWatermark( DtU32 size );
200  virtual bool setReceiveLowWatermark( DtU32 size );
201  virtual bool setMcastDevice( const DtInetAddr& devAddr );
202  virtual bool setMcastDevice( DtInetDevice* hostIf );
203 
204  virtual DtU32 getSendBufferSize();
205  virtual DtU32 getReceiveBufferSize();
206  virtual DtU32 getBytesAvailable();
207  virtual bool getBroadcastOption();
208  virtual bool getReuseAddressOption();
209  virtual bool getDoNotRouteOption();
210  virtual DtU32 getSendLowWatermark();
211  virtual DtU32 getReceiveLowWatermark();
213 
222  virtual bool joinMulticastGroup( const DtInetAddr& grpAddr,
223  DtInetDevice* device = NULL );
224  virtual bool joinMulticastGroup( const DtInetEndpoint& grpEndpoint,
225  DtInetDevice* device = NULL );
226  virtual bool dropMulticastGroup( const DtInetAddr& grpAddr,
227  DtInetDevice* device = NULL );
228  virtual bool dropMulticastGroup( const DtInetEndpoint& grpEndpoint,
229  DtInetDevice* device = NULL );
232  virtual bool setMcastTtlOption( DtU32 ttl );
234 
237  virtual void* udpSocket();
238 
243  virtual void* secondUdpSocket();
244 
245 protected:
246 
247 private:
249  DtInetUdpSocket( const DtInetUdpSocket& orig );
250 
252  DtInetUdpSocket& operator=(const DtInetUdpSocket& orig);
253 
255  friend class DtInetUdpSockPimpl;
256  DtInetUdpSockPimpl* myAsyncPimpl;
257 
258 protected:
259  void* myIoService;
260  void* myUdpSocket;
261  //A second socket is only opened in the case that we're running linux AND
262  //we want to bind a socket to a specific device address while using broadcast
263  //This isn't possible with one boost socket, so we make a second just to listen for broadcast messages.
265 
268  // Since DtInetAddr can be either an IPv4 or IPv6 address the use of a
269  // std::map would be problematic since there's no easy way to compare
270  // addresses without defining a predicate functor.
271  typedef std::pair<DtInetAddr, DtInetAddr> DtInetMcastGroupIntfcBinding;
272  typedef std::vector<DtInetMcastGroupIntfcBinding> DtInetMcastGroupBindings;
275 
276 };
277 // end of class DtInetUdpSocket
278 
279 #ifdef DtUSE_UTILITIES_NAMESPACE
280 }
281 #endif
282 
283 
284 
This file contains the declaration of the DtInetSocket base class.
DtInetSockRcvStatus
Socket state enumeration.
Definition: vlInetSocket.h:129
std::vector< DtInetBuffer * > DtInetBufferChain
Socket state enumeration.
Definition: vlInetSocket.h:105
Used to set and maintain time in a simulation.
Definition: vlTime.h:25
The DtInetSocket class provides a protocol independant, address family independant base class for TCP...
Definition: vlInetSocket.h:201
std::vector< DtInetMcastGroupIntfcBinding > DtInetMcastGroupBindings
Definition: vlInetUdpSocket.h:272
int recv(int s, char *buf, int bufLen, int flags)
std::pair< DtInetAddr, DtInetAddr > DtInetMcastGroupIntfcBinding
Associate the multicast group address with the host interface address the group is joined from...
Definition: vlInetUdpSocket.h:271
The DtInetEndpoint class provides a protocol independant, address family independent mechanism to rep...
Definition: vlInetEndpoint.h:33
Represents a IPv4 or IPv6 address.
Definition: vlInetAddr.h:36
Definition: vlInetDevice.h:101
void * myIoService
Definition: vlInetUdpSocket.h:259
void * mySecondUdpSocket
Definition: vlInetUdpSocket.h:264
DtInetMcastGroupBindings myMcastGroups
Definition: vlInetUdpSocket.h:273
void * myUdpSocket
Definition: vlInetUdpSocket.h:260
unsigned short DtU16
A 16 bit unsigned integer value.
Definition: vlMachineTypes.h:140
int send(int s, char *buf, int bufLen, int flags)
An abstract base class to represent a Socket Type.
Definition: vlInetUdpSocket.h:24
unsigned long DtU32
A 32 bit unsigned integer value.
Definition: vlMachineTypes.h:153
DtInetUdpSockPimpl * myAsyncPimpl
Definition: vlInetUdpSocket.h:256
#define DtDefaultSockOpts
Marks the Socket as Writable.
Definition: vlInetSocket.h:90
#define DT_DLL_VLUTIL
Definition: vlMachineTypes.h:109
DtClock myReceiveClock
Definition: vlInetUdpSocket.h:274

Document ID: Generated on Tue Aug 10 00:12:31 EDT 2021 from SVN revision 232765
Copyright © 2005-2021 MAK Technologies. All Rights Reserved (www.mak.com)