![]() |
VR-Link API Documentation for HLA 1516
|
An implementation of DtSocket which uses a TCP connection. More...
Inheritance diagram for DtTcpSocket:
Collaboration diagram for DtTcpSocket:Public Member Functions | |
| DtTcpSocket (int socketfd, DtIpv4Addr addr, int clientPort=0) | |
| Server Constructor. | |
| DtTcpSocket (DtIpv4Addr addr, int port=DtDEFAULT_PORT, int nonBlockingConnect=0) | |
| Client Constructor. | |
| virtual | ~DtTcpSocket () |
| Destructor. | |
| virtual int | sendTo (caddr_t packet, size_t packetSize, DtIpv4Addr addr=DtUSE_DEFAULT_IP_ADDR) |
| Returns size of packet sent. | |
| virtual int | DtRecv (caddr_t *buffptr, int *status=NULL) |
| DtReceiv is he function which VR-Link uses to read packets from the socket. | |
| virtual int | DtRecv (caddr_t buff, size_t bufsize) |
| virtual DtFlushStatus | flush () |
| Send buffered messages. | |
| virtual DtFlushStatus | flush (long &byteCount) |
| Send buffered messages. | |
| virtual void | DtBecomeNonBlocking () |
| Designate the socket as non-blocking. | |
| virtual void | DtBecomeBlocking () |
| Designate the socket as blocking. | |
| virtual bool | isOk () const |
| passively checks for errors in the socket. | |
| virtual bool | isConnectionEstablished () |
| checks if the connection is fully established by sending a minimal packet through the socket. | |
| virtual bool | testConnectionStatus () |
| actively test the connection for socket errors. | |
| DtIpv4Addr | getConnectionAddr () const |
| Get the address of the connected remote host. | |
| int | sizeOffset () const |
| Get/Set mySizeOffset. | |
| void | setSizeOffset (int offset) |
| int | sizeLength () const |
| Get/Set mySizeLength. | |
| void | setSizeLength (int length) |
| virtual void | setNoDelay (bool onOff) |
| Sets the TCP_NODELAY sockopt to 1 if onOff is true, 0 otherwise. | |
| virtual int | peerPort () const |
| Returns the port connected to on the remote host. | |
| virtual int | localPort () const |
| Returns the port bound to on the local host. | |
| int | maxForwarderQueue () const |
| Get/Set the max forwarder queue size. | |
| void | setMaxForwarderQueue (int maxForwarderQueue) |
| std::pair< int, int > | getQueueStatus () const |
| Returns the queue status int 1 - the packet wait list ( myPktWaitList ) count int 2 - the max forwarder queue size. | |
Static Public Member Functions | |
| static void | setNoDelay (int sockfd, bool onOff) |
| Sets the TCP_NODELAY sockopt to 1 if onOff is true, 0 otherwise. | |
| static void | setPacketBufferSize (int size) |
| Set the default buffer size for receiving data. | |
Protected Member Functions | |
| int | sendTo (caddr_t packet, size_t packetSize, bool reportMinSizePktFaults) |
| Returns size of packet sent. | |
| int | recvWithStatus (caddr_t *buffptr, int *status) |
| int | checkSize (int size, caddr_t *buffptr, int *status) |
| bool | expandPktBuffer (unsigned int sizeNeeded) |
| int | sendMinimumSizePkt (bool reportMinSizePktFaults) |
Protected Attributes | |
| char * | myPktBuff |
| unsigned int | myPktBuffSize |
| DtIpv4Addr | myConnectAddr |
| int | myPeerPort |
| int | myLocalPort |
| bool | myOk |
| int | myNeedSize |
| int | mySizeOffset |
| int | mySizeLength |
| int | myNumBytesToWaitFor |
| int | myNumBytesReceived |
| DtList * | myPktWaitList |
| List for saving un-sent packets. | |
| int | myMaxForwarderQueue |
| Max forwarder queue size. | |
Static Protected Attributes | |
| static int | thePktBuffSize |
Private Member Functions | |
| DtTcpSocket (const DtTcpSocket &) | |
| Copy CTOR Not Implemented. | |
| DtTcpSocket & | operator= (const DtTcpSocket &) |
| Assignment Operator Not Implemented. | |
An implementation of DtSocket which uses a TCP connection.
| DtTcpSocket::DtTcpSocket | ( | int | socketfd, |
| DtIpv4Addr | addr, | ||
| int | clientPort = 0 |
||
| ) |
Server Constructor.
| DtTcpSocket::DtTcpSocket | ( | DtIpv4Addr | addr, |
| int | port = DtDEFAULT_PORT, |
||
| int | nonBlockingConnect = 0 |
||
| ) |
Client Constructor.
| virtual DtTcpSocket::~DtTcpSocket | ( | ) | [virtual] |
Destructor.
| DtTcpSocket::DtTcpSocket | ( | const DtTcpSocket & | ) | [private] |
Copy CTOR Not Implemented.
| int DtTcpSocket::checkSize | ( | int | size, |
| caddr_t * | buffptr, | ||
| int * | status | ||
| ) | [protected] |
| virtual void DtTcpSocket::DtBecomeBlocking | ( | ) | [virtual] |
Designate the socket as blocking.
| virtual void DtTcpSocket::DtBecomeNonBlocking | ( | ) | [virtual] |
Designate the socket as non-blocking.
Reimplemented from DtSocket.
| virtual int DtTcpSocket::DtRecv | ( | caddr_t * | buffptr, |
| int * | status = NULL |
||
| ) | [virtual] |
DtReceiv is he function which VR-Link uses to read packets from the socket.
Users who wish to provide another mechanisim, such as shared memory, or loopback, will need to impliment or override these functions to return new packets. Depending on the implementation in derived DtSockets, one of the forms of DtRecv may be faster than the other.
DtRecv has an optional status argument that could more elegantly be implemented as different return codes, but this would break older code.
Implements DtSocket.
| virtual int DtTcpSocket::DtRecv | ( | caddr_t | buff, |
| size_t | |||
| ) | [virtual] |
| bool DtTcpSocket::expandPktBuffer | ( | unsigned int | sizeNeeded | ) | [protected] |
| virtual DtFlushStatus DtTcpSocket::flush | ( | ) | [virtual] |
Send buffered messages.
Returns the status indicating error, flush is complete or incomplete.
Reimplemented from DtSocket.
| virtual DtFlushStatus DtTcpSocket::flush | ( | long & | byteCount | ) | [virtual] |
Send buffered messages.
Number of flushed bytes returned in provided parameter. Returns the status indicating error, flush is complete or incomplete.
Reimplemented from DtSocket.
| DtIpv4Addr DtTcpSocket::getConnectionAddr | ( | ) | const [inline] |
Get the address of the connected remote host.
| std::pair<int, int> DtTcpSocket::getQueueStatus | ( | ) | const |
Returns the queue status int 1 - the packet wait list ( myPktWaitList ) count int 2 - the max forwarder queue size.
| virtual bool DtTcpSocket::isConnectionEstablished | ( | ) | [virtual] |
checks if the connection is fully established by sending a minimal packet through the socket.
This should be checked after checking isOk().
| bool DtTcpSocket::isOk | ( | ) | const [inline, virtual] |
passively checks for errors in the socket.
A result of true does not mean that the socket is fully connected.
Reimplemented from DtSocket.
| virtual int DtTcpSocket::localPort | ( | ) | const [virtual] |
Returns the port bound to on the local host.
| int DtTcpSocket::maxForwarderQueue | ( | ) | const |
Get/Set the max forwarder queue size.
| DtTcpSocket& DtTcpSocket::operator= | ( | const DtTcpSocket & | ) | [private] |
Assignment Operator Not Implemented.
| virtual int DtTcpSocket::peerPort | ( | ) | const [virtual] |
Returns the port connected to on the remote host.
| int DtTcpSocket::recvWithStatus | ( | caddr_t * | buffptr, |
| int * | status | ||
| ) | [protected] |
| int DtTcpSocket::sendMinimumSizePkt | ( | bool | reportMinSizePktFaults | ) | [protected] |
| virtual int DtTcpSocket::sendTo | ( | caddr_t | packet, |
| size_t | packetSize, | ||
| DtIpv4Addr | addr = DtUSE_DEFAULT_IP_ADDR |
||
| ) | [virtual] |
| int DtTcpSocket::sendTo | ( | caddr_t | packet, |
| size_t | packetSize, | ||
| bool | reportMinSizePktFaults | ||
| ) | [protected] |
Returns size of packet sent.
Allows caller to specify whether to report send errors for minimum size messages ( for example, when checking non-blocking connect status, errors should not be reported )
| void DtTcpSocket::setMaxForwarderQueue | ( | int | maxForwarderQueue | ) |
| virtual void DtTcpSocket::setNoDelay | ( | bool | onOff | ) | [virtual] |
Sets the TCP_NODELAY sockopt to 1 if onOff is true, 0 otherwise.
Default is 1.
| static void DtTcpSocket::setNoDelay | ( | int | sockfd, |
| bool | onOff | ||
| ) | [static] |
Sets the TCP_NODELAY sockopt to 1 if onOff is true, 0 otherwise.
Default is 1.
| static void DtTcpSocket::setPacketBufferSize | ( | int | size | ) | [static] |
Set the default buffer size for receiving data.
The packet buffer is only created once (in the constructor), so it is important to call the function below before creating a TcpSocket if you want the buffer to be larger than the default value of 20000 bytes.
| void DtTcpSocket::setSizeLength | ( | int | length | ) |
| void DtTcpSocket::setSizeOffset | ( | int | offset | ) |
| int DtTcpSocket::sizeLength | ( | ) | const [inline] |
Get/Set mySizeLength.
| int DtTcpSocket::sizeOffset | ( | ) | const [inline] |
Get/Set mySizeOffset.
| virtual bool DtTcpSocket::testConnectionStatus | ( | ) | [virtual] |
actively test the connection for socket errors.
sends a minimal size packet and returns false if any socket errors detected. Unlike isConnectionEstablished() a size 0 send is acceptable. This should be checked after checking isOk(). Failure sets isOk() to false.
DtIpv4Addr DtTcpSocket::myConnectAddr [protected] |
int DtTcpSocket::myLocalPort [protected] |
int DtTcpSocket::myMaxForwarderQueue [protected] |
Max forwarder queue size.
int DtTcpSocket::myNeedSize [protected] |
int DtTcpSocket::myNumBytesReceived [protected] |
int DtTcpSocket::myNumBytesToWaitFor [protected] |
bool DtTcpSocket::myOk [protected] |
int DtTcpSocket::myPeerPort [protected] |
char* DtTcpSocket::myPktBuff [protected] |
unsigned int DtTcpSocket::myPktBuffSize [protected] |
DtList* DtTcpSocket::myPktWaitList [protected] |
List for saving un-sent packets.
Calling flush will attempt to empty this list.
int DtTcpSocket::mySizeLength [protected] |
int DtTcpSocket::mySizeOffset [protected] |
int DtTcpSocket::thePktBuffSize [static, protected] |