VR-Link API Documentation for HLA 1516
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
List of all members | Public Member Functions | Protected Types | Protected Member Functions | Static Protected Member Functions | Protected Attributes | Static Protected Attributes | Private Member Functions

A Socket which starts a thread which is continuously reading and writing from packet queues. More...

+ Inheritance diagram for DtAsyncNetSocket:
+ Collaboration diagram for DtAsyncNetSocket:

Public Member Functions

 DtAsyncNetSocket (int port=DtDEFAULT_PORT, DtU8 flags=DtReadWrite, DtIpv4Addr devAddr=0)
 
 DtAsyncNetSocket (int port, DtIpv4Addr destAddr, DtU8 flags, DtIpv4Addr devAddr=0)
 
 DtAsyncNetSocket (char *dummy, int sockfd, DtU8 flags=DtReadWrite)
 
virtual ~DtAsyncNetSocket ()
 Destructor. More...
 
virtual int sendTo (caddr_t packet, size_t size, DtIpv4Addr addr)
 Virtual function override. More...
 
virtual int directSendTo (caddr_t packet, size_t size, DtIpv4Addr addr)
 sends the packet directly to the network and bypasses the message queue and sender thread. More...
 
virtual bool usingAsyncSend () const
 Get/Set functions to configure AsyncOutput (True by default) More...
 
virtual void setUsingAsyncSend (bool b)
 
virtual bool usingAsyncReceive () const
 Get/Set function for configuring AsyncInput. (True by default) More...
 
virtual void setUsingAsyncReceive (bool b)
 
- Public Member Functions inherited from DtNetSocket
 DtNetSocket (int port=DtDEFAULT_PORT, DtU8 flags=DtReadWrite, DtIpv4Addr devAddr=0)
 Constructor. More...
 
 DtNetSocket (int port, DtIpv4Addr destAddr, DtU8 flags, DtIpv4Addr devAddr=0)
 Constructor. More...
 
 DtNetSocket (char *dummy, int sockfd, DtU8 flags=DtReadWrite)
 Allows you to create a DtNetSocket that uses a pre-existing socket. More...
 
virtual ~DtNetSocket ()
 Destructor. More...
 
virtual int DtRecv (caddr_t *buffptr, int *status=NULL)
 DtNetSocket implements DtRecv by calling a system call to recvfrom on its UDP socket. More...
 
virtual int DtRecv (caddr_t buff, size_t)
 DtNetSocket implements DtRecv by calling a system call to recvfrom on its UDP socket. More...
 
virtual DtIpv4Addr lastSourceInetAddr ()
 Return the IP address of the sender of the last packet we've received. More...
 
virtual void DtBecomeNonBlocking (void)
 Make the socket non-blocking. More...
 
virtual int readFd ()
 Return read/write file descriptor of the UDP socket being used for sending and receiving. More...
 
virtual int writeFd ()
 
virtual bool isOk () const
 Returns 1 if the socket's constructor initialization was successful, 0 otherwise. More...
 
virtual int setMcastTtl (int ttl)
 Set the TTL (time to live) value for multicast packets. More...
 
virtual void setFilterPort (const int &port)
 
virtual void setSendPort (const int &port)
 
virtual void setBundling (int maxBundleSize, bool enableUnbundling, int minPacketSize, int sizeOffset, int sizeLength, bool testDisHeader)
 Set all bundling parameters Disables bundling if max. More...
 
virtual void setBundling (int maxBundleSize)
 Call through to DtSocket::setBundling to prevent compiler warnings. More...
 
virtual void setUnbundling (int onOff)
 Pass 0 to setUnbundling to turn unbundling off, 1 to turn it on. More...
 
virtual int isUnbundling ()
 Set all bundling parameters Disables bundling if max. More...
 
virtual int minPacketSize ()
 
virtual void setMinPacketSize (int size)
 
virtual int sizeOffset ()
 
virtual void setSizeOffset (int offset)
 
virtual int sizeLength ()
 
virtual void setSizeLength (int length)
 
virtual bool testDisHeader ()
 
virtual void enableDisHeaderTest (bool shouldTest)
 
virtual int listenToMulticastGroup (DtIpv4Addr multicastAddr, DtIpv4Addr netInterface=DtUSE_DEFAULT_IP_ADDR)
 
virtual int dropMulticastGroup (DtIpv4Addr multicastAddr, DtIpv4Addr netInterface=DtUSE_DEFAULT_IP_ADDR)
 
virtual void setMcastDevice (DtIpv4Addr devAddr)
 
virtual DtIpv4Addr mcastDevice () const
 
- Public Member Functions inherited from DtSocket
 DtSocket ()
 Default constructor. More...
 
virtual ~DtSocket ()
 Default Destructor. More...
 
virtual int DtSend (caddr_t packet, size_t size, DtIpv4Addr addr=DtUSE_DEFAULT_IP_ADDR)
 DtSend is called when someone wants to send a packet to this "Socket", in other words, all outgoing messages are passed to this socket via DtSend(). More...
 
caddr_t DtRecv ()
 
virtual DtFlushStatus flush ()
 Send buffered messages. More...
 
virtual DtFlushStatus flush (long &byteCount)
 Send buffered messages. More...
 
virtual void setReceiveBufferSize (int newsize)
 Change the socket's receive buffer size that the OS uses to collect incoming data from the network. More...
 
virtual void setSendBufferSize (int newsize)
 Change the socket's send buffer size that the OS uses when writing data to the network. More...
 
virtual int isBundling ()
 
virtual int DtReportPktsRcvd (void)
 
virtual void notifyMe ()
 
virtual DtFilterTestexerciseId ()
 
virtual DtFilterTestprotocolVersion ()
 
virtual DtFilterTestpduKind ()
 
virtual DtFilterTestipAddr ()
 

Protected Types

typedef DtThreadSafe
< std::deque
< DtAsyncSocketPacket > > 
ThreadSafePacketQueue
 
- Protected Types inherited from DtSocket
typedef std::vector< char > Buffer
 
typedef std::map< DtIpv4Addr,
Buffer
BufferMap
 

Protected Member Functions

virtual int recvFromNet (caddr_t *buffptr)
 Virtual Function override, this function instead of reading from the socket, reads from the message queue. More...
 
void initThread ()
 Non virtual, called from the constructor. More...
 
virtual void workerSendThread ()
 Work function which is the main function in the Send Thread. More...
 
virtual void workerReceiveThread ()
 Work function which is the main function in the Receive Thread. More...
 
virtual void processSendQueue ()
 Called from the Send thread to process all messages in the list. More...
 
virtual void processReceiveQueue ()
 called from the Receive thread to receive ONE packet. More...
 
- Protected Member Functions inherited from DtNetSocket
void init (int port, DtIpv4Addr dest_addr, DtU8 flags, DtIpv4Addr devAddr=0)
 Called from all constructors. More...
 
virtual int dataLeftInCurrentBundle ()
 Is there still data left in the last received packet? More...
 
virtual int retrySendTo (caddr_t packet, size_t size, sockaddr_in &dest)
 If retry is enabled, retry failed packet send theMaxSendRetries times. More...
 
virtual int recvWithStatus (caddr_t *buffptr, int *status)
 Sets buffptr to point to the next packet (might be next in bundle, might require a read from net) and returns size. More...
 
virtual int recvWithUnbundling (caddr_t *buffptr)
 Used by recvWithStatus if unbundling is on. More...
 
int initSocket ()
 Initialize the socket. More...
 
int initWrite (DtIpv4Addr dest)
 Initialize for writing. More...
 
int initRead (DtIpv4Addr dest)
 Initialize for reading, including performing bind. More...
 
virtual int privateListenToMulticastGroup (DtIpv4Addr multicastAddr, int on_init=0, DtIpv4Addr netInterface=DtUSE_DEFAULT_IP_ADDR)
 Helper function for listenToMulticastGroup. More...
 
virtual void findNextPacket ()
 Sets myNextPacket to point to the next packet. More...
 
virtual unsigned int getNextPacketSize ()
 Gets the size of the next packet pointed to by myNextPacket. More...
 
virtual unsigned int currentHeaderMatchesFirstInBundle ()
 DIS-specific function to help decide if unbundling is successful. More...
 
 DtNetSocket (const DtNetSocket &)
 Not Implemented. More...
 
DtNetSocketoperator= (const DtNetSocket &)
 Not Implemented. More...
 
- Protected Member Functions inherited from DtSocket
virtual bool accept (char *buf, DtIpv4Addr iaddr)
 

Static Protected Member Functions

static void * runReceive (void *usr_data)
 These functions just call the WorkerSendThread and the WorkerReceiveThread. More...
 
static void * runSend (void *usr_data)
 
static void setQueueTimeout (double new_time_out)
 
static double queueTimeout ()
 
- Static Protected Member Functions inherited from DtNetSocket
static ifreq * findIfr (const char *device, int sock, ifconf *ifc)
 Find a device. More...
 
static DtIpv4Addr netMaskOfIfr (ifreq *ifr, int sock)
 Obtain information about a device. Dummy socket needed for ioctls. More...
 
static DtIpv4Addr inetAddrOfIfr (ifreq *ifr, int sock)
 
static DtIpv4Addr inetBroadcastOfIfr (ifreq *ifr, int sock)
 
static bool capableOfIpBroadcast (ifreq *ifr, int sock)
 
- Static Protected Member Functions inherited from DtSocket
static int getConfig (const char *device, int sock, ifconf *ifc)
 Get ifconfig information by filling in ifc. More...
 

Protected Attributes

bool myUseAsyncSendFlag
 
bool myUseAsyncReceiveFlag
 
ThreadSafePacketQueue mySendQueue
 A type save queue for sending messages to the network writer. More...
 
ThreadSafePacketQueue myReceiveQueue
 A type safe queue for getting messages from the network reader. More...
 
volatile bool myTimeToQuitSender
 
volatile bool myTimeToQuitReceiver
 
char * myThreadPktBuff
 
pthread_t mySendThreadHandle
 
pthread_t myReceiveThreadHandle
 
int mySendEvent [2]
 
- Protected Attributes inherited from DtNetSocket
int myUdpPort
 
int myFilterPort
 
int mySendPort
 
unsigned int mySourcePort
 
char * myPktBuff
 
char * myUnbundleBuff
 
void * myNextPacket
 
int myUsingExternalSocket
 
DtIpv4Addr myExtSockAddr
 
DtIpv4Addr myDestInetAddr
 
DtIpv4Addr myDevAddr
 
int myUnbundling
 
int sizeLeft
 
int myPktMinSize
 
int myPktSizeOffset
 
int myPktSizeLength
 
int myMaxPacketSize
 
bool myTestingDisHeader
 
int boundToDestAddr
 
int firstInBundle
 
int firstExId
 
int firstProtocol
 
bool myOkFlag
 
sockaddr_in * destSockAddr
 
sockaddr_in * sourceSockAddr
 
DtU8 myFlags
 
- Protected Attributes inherited from DtSocket
BufferMap myBufferMap
 
int myBundlingFlag
 
int myMaxBundleSize
 
int mySockFd
 

Static Protected Attributes

static double theQueueTimeout
 The TimeOut in the send Thread, in seconds. More...
 
- Static Protected Attributes inherited from DtNetSocket
static unsigned int theMaxSendRetries
 
static double theSendRetryPeriod
 
- Static Protected Attributes inherited from DtSocket
static bool theAreQuietSockets
 Should a socket print messages, informative or error. More...
 

Private Member Functions

 DtAsyncNetSocket (const DtAsyncNetSocket &)
 Copy CTOR Not Implemented. More...
 
DtAsyncNetSocketoperator= (const DtAsyncNetSocket &)
 Assignment Operator Not Implemented. More...
 

Additional Inherited Members

- Static Public Member Functions inherited from DtNetSocket
static int isMulticastAddr (DtIpv4Addr addr)
 Returns 1 if addr is a multicast address, 0 otherwise. More...
 
static int enableBroadcast (int sockfd)
 Make sockfd capable of broadcasting. More...
 
static void makeNonBlocking (int sockfd)
 Make sockfd non-blocking. More...
 
static int makeReusable (int sockfd)
 Make port/address reusable by other sockets. More...
 
static void setRetryOnSend (unsigned int numRetries, double waitPeriod)
 Make socket retry numRetries times ( waiting for waitPeriod between ) when sendto fails ( numRetries = 0 means message will be dropped ) More...
 
static DtIpv4Addr inetBroadcastOfDevice (const char *device=NULL)
 Obtain information about a device. More...
 
static DtIpv4Addr inetAddrOfDevice (const char *device=NULL)
 
static DtIpv4Addr netMaskOfDevice (const char *device=NULL)
 
static DtIpv4Addr firstHostInetAddr ()
 
static void setInetAddr (sockaddr_in &s, u_long addr, int port)
 Fill out a sockaddr_in structure. More...
 
- Static Public Member Functions inherited from DtSocket
static void initializeNetwork ()
 
static void setQuietSockets (bool quietVal)
 These functions determine whether a socket will print messages, informative or error. More...
 
static bool areQuietSockets ()
 
- Public Attributes inherited from DtSocket
int myBlockingFlag
 
int pkts_rcvd
 
- Static Public Attributes inherited from DtNetSocket
static DtInitErrorAction initErrorAction
 

Detailed Description

A Socket which starts a thread which is continuously reading and writing from packet queues.

All messages sent out into the world go onto a Send Queue. Messages read off the network come from a Receive Queue

Deprecated:
This class is replaced by DtInetSocket as of VR-Link 3.13

Member Typedef Documentation

Constructor & Destructor Documentation

DtAsyncNetSocket::DtAsyncNetSocket ( int  port = DtDEFAULT_PORT,
DtU8  flags = DtReadWrite,
DtIpv4Addr  devAddr = 0 
)
DtAsyncNetSocket::DtAsyncNetSocket ( int  port,
DtIpv4Addr  destAddr,
DtU8  flags,
DtIpv4Addr  devAddr = 0 
)
DtAsyncNetSocket::DtAsyncNetSocket ( char *  dummy,
int  sockfd,
DtU8  flags = DtReadWrite 
)
virtual DtAsyncNetSocket::~DtAsyncNetSocket ( )
virtual

Destructor.

DtAsyncNetSocket::DtAsyncNetSocket ( const DtAsyncNetSocket )
private

Copy CTOR Not Implemented.

Member Function Documentation

virtual int DtAsyncNetSocket::directSendTo ( caddr_t  packet,
size_t  size,
DtIpv4Addr  addr 
)
virtual

sends the packet directly to the network and bypasses the message queue and sender thread.

void DtAsyncNetSocket::initThread ( )
protected

Non virtual, called from the constructor.

DtAsyncNetSocket& DtAsyncNetSocket::operator= ( const DtAsyncNetSocket )
private

Assignment Operator Not Implemented.

virtual void DtAsyncNetSocket::processReceiveQueue ( )
protectedvirtual

called from the Receive thread to receive ONE packet.

virtual void DtAsyncNetSocket::processSendQueue ( )
protectedvirtual

Called from the Send thread to process all messages in the list.

It will not return until the list is empty.

double DtAsyncNetSocket::queueTimeout ( )
inlinestaticprotected
virtual int DtAsyncNetSocket::recvFromNet ( caddr_t *  buffptr)
protectedvirtual

Virtual Function override, this function instead of reading from the socket, reads from the message queue.

Reimplemented from DtNetSocket.

static void* DtAsyncNetSocket::runReceive ( void *  usr_data)
staticprotected

These functions just call the WorkerSendThread and the WorkerReceiveThread.

static void* DtAsyncNetSocket::runSend ( void *  usr_data)
staticprotected
virtual int DtAsyncNetSocket::sendTo ( caddr_t  packet,
size_t  size,
DtIpv4Addr  addr 
)
virtual

Virtual function override.

DtAsyncNetSocket implements sendTo by placing the packet on the send queue. The worker thread will read it off the queue and send it out to the world using DtNetSocket::sendTo(...). The only difference is that this function queues it first.

Reimplemented from DtNetSocket.

void DtAsyncNetSocket::setQueueTimeout ( double  new_time_out)
inlinestaticprotected
void DtAsyncNetSocket::setUsingAsyncReceive ( bool  b)
inlinevirtual
void DtAsyncNetSocket::setUsingAsyncSend ( bool  b)
inlinevirtual
bool DtAsyncNetSocket::usingAsyncReceive ( ) const
inlinevirtual

Get/Set function for configuring AsyncInput. (True by default)

bool DtAsyncNetSocket::usingAsyncSend ( ) const
inlinevirtual

Get/Set functions to configure AsyncOutput (True by default)

virtual void DtAsyncNetSocket::workerReceiveThread ( )
protectedvirtual

Work function which is the main function in the Receive Thread.

virtual void DtAsyncNetSocket::workerSendThread ( )
protectedvirtual

Work function which is the main function in the Send Thread.

Member Data Documentation

ThreadSafePacketQueue DtAsyncNetSocket::myReceiveQueue
protected

A type safe queue for getting messages from the network reader.

pthread_t DtAsyncNetSocket::myReceiveThreadHandle
protected
int DtAsyncNetSocket::mySendEvent[2]
protected
ThreadSafePacketQueue DtAsyncNetSocket::mySendQueue
protected

A type save queue for sending messages to the network writer.

pthread_t DtAsyncNetSocket::mySendThreadHandle
protected
char* DtAsyncNetSocket::myThreadPktBuff
protected
volatile bool DtAsyncNetSocket::myTimeToQuitReceiver
protected
volatile bool DtAsyncNetSocket::myTimeToQuitSender
protected
bool DtAsyncNetSocket::myUseAsyncReceiveFlag
protected
bool DtAsyncNetSocket::myUseAsyncSendFlag
protected
double DtAsyncNetSocket::theQueueTimeout
staticprotected

The TimeOut in the send Thread, in seconds.


The documentation for this class was generated from the following file:

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)