![]() |
VR-Link API Documentation for HLA 1.3
|
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. | |
| virtual int | sendTo (caddr_t packet, size_t size, DtIpv4Addr addr) |
| Virtual function override. | |
| 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. | |
| virtual bool | usingAsyncSend () const |
| Get/Set functions to configure AsyncOutput (True by default) | |
| virtual void | setUsingAsyncSend (bool b) |
| virtual bool | usingAsyncReceive () const |
| Get/Set function for configuring AsyncInput. (True by default) | |
| virtual void | setUsingAsyncReceive (bool b) |
Protected Types | |
| typedef DtThreadSafe < std::deque < DtAsyncSocketPacket > > | ThreadSafePacketQueue |
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. | |
| void | initThread () |
| Non virtual, called from the constructor. | |
| virtual void | workerSendThread () |
| Work function which is the main function in the Send Thread. | |
| virtual void | workerReceiveThread () |
| Work function which is the main function in the Receive Thread. | |
| virtual void | processSendQueue () |
| Called from the Send thread to process all messages in the list. | |
| virtual void | processReceiveQueue () |
| called from the Receive thread to receive ONE packet. | |
Static Protected Member Functions | |
| static void * | runReceive (void *usr_data) |
| These functions just call the WorkerSendThread and the WorkerReceiveThread. | |
| static void * | runSend (void *usr_data) |
| static void | setQueueTimeout (double new_time_out) |
| static double | queueTimeout () |
Protected Attributes | |
| bool | myUseAsyncSendFlag |
| bool | myUseAsyncReceiveFlag |
| ThreadSafePacketQueue | mySendQueue |
| A type save queue for sending messages to the network writer. | |
| ThreadSafePacketQueue | myReceiveQueue |
| A type safe queue for getting messages from the network reader. | |
| volatile bool | myTimeToQuitSender |
| volatile bool | myTimeToQuitReceiver |
| char * | myThreadPktBuff |
| pthread_t | mySendThreadHandle |
| pthread_t | myReceiveThreadHandle |
| int | mySendEvent [2] |
Static Protected Attributes | |
| static double | theQueueTimeout |
| The TimeOut in the send Thread, in seconds. | |
Private Member Functions | |
| DtAsyncNetSocket (const DtAsyncNetSocket &) | |
| Copy CTOR Not Implemented. | |
| DtAsyncNetSocket & | operator= (const DtAsyncNetSocket &) |
| Assignment Operator Not Implemented. | |
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
typedef DtThreadSafe<std::deque<DtAsyncSocketPacket> > DtAsyncNetSocket::ThreadSafePacketQueue [protected] |
| 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.
| 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 | ( | ) | [protected, virtual] |
called from the Receive thread to receive ONE packet.
| virtual void DtAsyncNetSocket::processSendQueue | ( | ) | [protected, virtual] |
Called from the Send thread to process all messages in the list.
It will not return until the list is empty.
| double DtAsyncNetSocket::queueTimeout | ( | ) | [inline, static, protected] |
| virtual int DtAsyncNetSocket::recvFromNet | ( | caddr_t * | buffptr | ) | [protected, virtual] |
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 | ) | [static, protected] |
These functions just call the WorkerSendThread and the WorkerReceiveThread.
| static void* DtAsyncNetSocket::runSend | ( | void * | usr_data | ) | [static, protected] |
| 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 | ) | [inline, static, protected] |
| void DtAsyncNetSocket::setUsingAsyncReceive | ( | bool | b | ) | [inline, virtual] |
| void DtAsyncNetSocket::setUsingAsyncSend | ( | bool | b | ) | [inline, virtual] |
| bool DtAsyncNetSocket::usingAsyncReceive | ( | ) | const [inline, virtual] |
Get/Set function for configuring AsyncInput. (True by default)
| bool DtAsyncNetSocket::usingAsyncSend | ( | ) | const [inline, virtual] |
Get/Set functions to configure AsyncOutput (True by default)
| virtual void DtAsyncNetSocket::workerReceiveThread | ( | ) | [protected, virtual] |
Work function which is the main function in the Receive Thread.
| virtual void DtAsyncNetSocket::workerSendThread | ( | ) | [protected, virtual] |
Work function which is the main function in the Send Thread.
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 [static, protected] |
The TimeOut in the send Thread, in seconds.