![]() |
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. More... | |
| DtTcpSocket (DtIpv4Addr addr, int port=DtDEFAULT_PORT, int nonBlockingConnect=0) | |
| Client Constructor. More... | |
| virtual | ~DtTcpSocket () |
| Destructor. More... | |
| virtual int | sendTo (caddr_t packet, size_t packetSize, DtIpv4Addr addr=DtUSE_DEFAULT_IP_ADDR) |
| Returns size of packet sent. More... | |
| virtual int | DtRecv (caddr_t *buffptr, int *status=NULL) |
| DtReceiv is he function which VR-Link uses to read packets from the socket. More... | |
| virtual int | DtRecv (caddr_t buff, size_t bufsize) |
| virtual DtFlushStatus | flush () |
| Send buffered messages. More... | |
| virtual DtFlushStatus | flush (long &byteCount) |
| Send buffered messages. More... | |
| virtual void | DtBecomeNonBlocking () |
| Designate the socket as non-blocking. More... | |
| virtual void | DtBecomeBlocking () |
| Designate the socket as blocking. More... | |
| virtual bool | isOk () const |
| passively checks for errors in the socket. More... | |
| virtual bool | isConnectionEstablished () |
| checks if the connection is fully established by sending a minimal packet through the socket. More... | |
| virtual bool | testConnectionStatus () |
| actively test the connection for socket errors. More... | |
| DtIpv4Addr | getConnectionAddr () const |
| Get the address of the connected remote host. More... | |
| int | sizeOffset () const |
| Get/Set mySizeOffset. More... | |
| void | setSizeOffset (int offset) |
| int | sizeLength () const |
| Get/Set mySizeLength. More... | |
| void | setSizeLength (int length) |
| virtual void | setNoDelay (bool onOff) |
| Sets the TCP_NODELAY sockopt to 1 if onOff is true, 0 otherwise. More... | |
| virtual int | peerPort () const |
| Returns the port connected to on the remote host. More... | |
| virtual int | localPort () const |
| Returns the port bound to on the local host. More... | |
| int | maxForwarderQueue () const |
| Get/Set the max forwarder queue size. More... | |
| 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. More... | |
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 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 void | setBundling (int maxSize) |
| virtual int | isBundling () |
| virtual void | setUnbundling (int) |
| virtual DtIpv4Addr | lastSourceInetAddr () |
| virtual int | DtReportPktsRcvd (void) |
| virtual void | notifyMe () |
| virtual int | listenToMulticastGroup (DtIpv4Addr addr, DtIpv4Addr netInterface=DtUSE_DEFAULT_IP_ADDR) |
| virtual int | dropMulticastGroup (DtIpv4Addr addr, DtIpv4Addr netInterface=DtUSE_DEFAULT_IP_ADDR) |
| virtual int | setMcastTtl (int) |
| virtual void | setMcastDevice (DtIpv4Addr) |
| virtual DtFilterTest * | exerciseId () |
| virtual DtFilterTest * | protocolVersion () |
| virtual DtFilterTest * | pduKind () |
| virtual DtFilterTest * | ipAddr () |
| virtual int | readFd () |
| Get the file descriptor for reading and writing to this socket. More... | |
| virtual int | writeFd () |
Static Public Member Functions | |
| static void | setNoDelay (int sockfd, bool onOff) |
| Sets the TCP_NODELAY sockopt to 1 if onOff is true, 0 otherwise. More... | |
| static void | setPacketBufferSize (int size) |
| Set the default buffer size for receiving data. 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 () |
Protected Member Functions | |
| int | sendTo (caddr_t packet, size_t packetSize, bool reportMinSizePktFaults) |
| Returns size of packet sent. More... | |
| 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 Member Functions inherited from DtSocket | |
| virtual bool | accept (char *buf, DtIpv4Addr iaddr) |
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. More... | |
| int | myMaxForwarderQueue |
| Max forwarder queue size. More... | |
Protected Attributes inherited from DtSocket | |
| BufferMap | myBufferMap |
| int | myBundlingFlag |
| int | myMaxBundleSize |
| int | mySockFd |
Static Protected Attributes | |
| static int | thePktBuffSize |
Static Protected Attributes inherited from DtSocket | |
| static bool | theAreQuietSockets |
| Should a socket print messages, informative or error. More... | |
Private Member Functions | |
| DtTcpSocket (const DtTcpSocket &) | |
| Copy CTOR Not Implemented. More... | |
| DtTcpSocket & | operator= (const DtTcpSocket &) |
| Assignment Operator Not Implemented. More... | |
Additional Inherited Members | |
Public Attributes inherited from DtSocket | |
| int | myBlockingFlag |
| int | pkts_rcvd |
Protected Types inherited from DtSocket | |
| typedef std::vector< char > | Buffer |
| typedef std::map< DtIpv4Addr, Buffer > | BufferMap |
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... | |
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 |
Destructor.
|
private |
Copy CTOR Not Implemented.
|
virtual |
Designate the socket as blocking.
|
virtual |
Designate the socket as non-blocking.
Reimplemented from DtSocket.
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 |
|
virtual |
Send buffered messages.
Returns the status indicating error, flush is complete or incomplete.
Reimplemented from DtSocket.
|
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.
|
inline |
Get the address of the connected remote host.
Returns the queue status int 1 - the packet wait list ( myPktWaitList ) count int 2 - the max forwarder queue size.
|
virtual |
checks if the connection is fully established by sending a minimal packet through the socket.
This should be checked after checking isOk().
|
inlinevirtual |
passively checks for errors in the socket.
A result of true does not mean that the socket is fully connected.
Reimplemented from DtSocket.
|
virtual |
Returns the port bound to on the local host.
| int DtTcpSocket::maxForwarderQueue | ( | ) | const |
Get/Set the max forwarder queue size.
|
private |
Assignment Operator Not Implemented.
|
virtual |
Returns the port connected to on the remote host.
|
virtual |
|
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 |
Sets the TCP_NODELAY sockopt to 1 if onOff is true, 0 otherwise.
Default is 1.
Sets the TCP_NODELAY sockopt to 1 if onOff is true, 0 otherwise.
Default is 1.
|
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 | ) |
|
inline |
Get/Set mySizeLength.
|
inline |
Get/Set mySizeOffset.
|
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.
|
protected |
|
protected |
|
protected |
Max forwarder queue size.
|
protected |
|
protected |
|
protected |
|
protected |
|
protected |
|
protected |
|
protected |
|
protected |
List for saving un-sent packets.
Calling flush will attempt to empty this list.
|
protected |
|
protected |
|
staticprotected |