![]() |
VR-Link API Documentation for HLA 1516
|
The DtDisSocket class provides an address family independent datagram socket. More...
Inheritance diagram for DtDisSocket:
Collaboration diagram for DtDisSocket:Classes | |
| struct | DtDisSocketPduHeader |
Public Member Functions | |
| DtDisSocket (const DtInetEndpoint &dest, DtU16 localPort=0, DtInetDevice *hostIf=NULL, DtU32 flags=DtDefaultSockOpts, bool immediateOpen=true, bool suppressSelfReflectEnabled=false) | |
| DIS Socket Constructor. | |
| virtual | ~DtDisSocket () |
| Destructor. | |
| virtual bool | openSocket () |
| Enable sending and receiving of packets. | |
| virtual bool | closeSocket () |
| Close a socket. | |
| virtual DtInetSockRcvStatus | recvFrom (caddr_t buff, size_t buffSize, DtInetEndpoint &src, DtU32 flags=0) |
| Receive method override The DtInetUdpSocket base class revcFrom() method does not perform unbundling, PDU filtering, or self-reflect suppression. | |
| virtual bool | addDestination (const DtInetEndpoint &destination) |
| Add an additional destination. | |
| virtual void | removeDestination (const DtInetEndpoint &destination) |
| Remove a destination. | |
| virtual DtPduFilterTest * | exerciseId () |
| DIS PDU filtering extension interface. | |
| virtual DtPduFilterTest * | protocolVersion () |
| virtual DtPduFilterTest * | pduKind () |
| virtual DtPduFilterTest * | ipAddr () |
| virtual DtInetEndpoint & | localSenderEndpoint () const |
| Return the endpoint of the sender. | |
| virtual DtInetSockFlushStatus | flush () |
| Flush bundles. This method is called to flush all queued bundles. | |
| virtual int | suppressSelfReflect (int size, DtInetBufferChain &buffChain, DtInetEndpoint &ep, int *status) |
| Supress self-reflection method. | |
| virtual int | filterExercisePdus (int size, DtInetBufferChain &buffChain, DtInetEndpoint &ep, int *status) |
| Filter out PDUs which match the parameters configured in the DtPduFilterTests. | |
| virtual int | minSizeFilter (int size, DtInetBufferChain &buffChain, DtInetEndpoint &ep, int *status) |
| Filter PDUs that are smaller than size of DIS PDU header. | |
| virtual void | setAttributePduStrategy (DtAttributePduStrategy strat) |
| Sets/Gets whether to parse for coupled attribute PDU. | |
| virtual DtAttributePduStrategy | attributePduStrategy () const |
Send methods. | |
The base class send methods are overridden to provide the optional capability to bundle/unbundle and to filter self-reflects by sending PDUs from a different socket on an ephemeral port | |
| virtual int | send (caddr_t packet, size_t size, DtU32 flags=0) |
| Sends only to the given destination. | |
| virtual int | sendTo (caddr_t packet, size_t size, DtInetEndpoint &dest, DtU32 flags=0) |
| Sends only to the given destination. | |
| virtual int | sendChain (DtInetBufferChain &packets, DtU32 flags=0) |
| Sends only to the given destination. | |
| virtual int | sendChainTo (DtInetBufferChain &packets, DtInetEndpoint &dest, DtU32 flags=0) |
| Sends only to the given destination. | |
Overridden socket options setters. | |
These methods are overridden to set the option on the send socket in addition to setting it on the main socket. | |
| virtual bool | setNonBlockingOption (bool onOrOff) |
| virtual bool | setSendBufferSize (DtU32 size) |
| virtual bool | setReceiveBufferSize (DtU32 size) |
| virtual bool | setBroadcastOption (bool onOrOff) |
| virtual bool | setReuseAddressOption (bool onOrOff) |
| virtual bool | setDoNotRouteOption (bool onOrOff) |
| virtual bool | setSendLowWatermark (DtU32 size) |
| virtual bool | setReceiveLowWatermark (DtU32 size) |
| virtual bool | setSendMcastDevice (const DtInetAddr &devAddr) |
| virtual bool | setMcastTtlOption (DtU32 ttl) |
| Change the default time-to-live on outbound multicast packets sent from this socket. | |
Multicast specific methods. | |
Join / drop subscription to multicast group. Socket will join group identified by the multicast address in grpAddr or grpEndpoint. If an object is passed in the port value of the endpoint will be ignored and the socket will join from the same port the socket's local endpoint uses. If no interface is specified in the join it will join on the host's default multicast interface. | |
| virtual bool | sendSockJoinMulticastGroup (DtInetAddr grpAddr, DtInetDevice *device=NULL) |
| virtual bool | sendSockJoinMulticastGroup (DtInetEndpoint grpEndpoint, DtInetDevice *device=NULL) |
| virtual bool | sendSockDropMulticastGroup (DtInetAddr grpAddr, DtInetDevice *device=NULL) |
| virtual bool | sendSockDropMulticastGroup (DtInetEndpoint grpEndpoint, DtInetDevice *device=NULL) |
DIS PDU bundling extension functions. | |
| virtual void | setBundling (int maxBundleSize, int sizeOffset, int sizeLength, bool testDisHeader) |
| Bundling is only performed when using the sendChain(), sendChainTo(), recvToChain(), and recvToChainFrom() methods. | |
Set / get bundle maximum bundle size. | |
Setting maximum bundle size > 0 enables bundling. Setting max bundle size to 0 disables bundling. For optimal network performance max bundle sizes should be slightly less than the MTU of the network. | |
| virtual bool | setMaxBundleSize (int size) |
| virtual int | getMaxBundleSize () |
| virtual bool | isBundling () |
Set / get minimum valid packet size. | |
The minimum sized packet that can be received. By default, size of DtDisSocketPduHeader | |
| virtual void | setMinPacketSize (int size) |
| virtual int | minPacketSize () |
Set / get inter PDU byte alignment in bytes | |
| virtual void | setBundleByteAlignment (DtU32 size) |
| virtual DtU32 | sendBundleByteAlignment () |
| virtual DtU32 | receiveBundleByteAlignment (int protocolVersion) |
Bundling methods. | |
These methods are called from the bundling callback functions to perform the actual work. | |
| virtual int | addToBundle (int size, DtInetBufferChain &buffChain, DtInetEndpoint &ep) |
| virtual int | unbundle (int size, DtInetBufferChain &buffChain, DtInetEndpoint &ep, int *status) |
| virtual int | getNextBundle (int size, DtInetBufferChain &buffChain, DtInetEndpoint &ep, int *status) |
| virtual DtInetSockFlushStatus | flushBundle (DtInetEndpoint &ep) |
Public Member Functions inherited from DtInetUdpSocket | |
| DtInetUdpSocket () | |
| Default Constructor. | |
| DtInetUdpSocket (const DtInetEndpoint &dest, DtU16 localPort=0, DtInetDevice *hostIf=NULL, DtU32 flags=DtDefaultSockOpts, bool immediateOpen=true) | |
| Client Socket Constructor. | |
| virtual | ~DtInetUdpSocket () |
| Destructor. | |
| virtual bool | setDestination (const DtInetEndpoint &dest) |
| Set / get the destination endpoint for the socket. | |
| virtual bool | bindToDevice (const DtInetDevice *hostIf=NULL) |
| Set the network interface device the socket will attempt to bind to on the local host. | |
| virtual bool | connectToDestination () |
| Initiate a connection to a single unicast destination endpoint. | |
| virtual bool | disconnect () |
| Dissolve any unicast connection and return to normal 'connectionless' operation. | |
| virtual bool | isOk () |
| Deprecated. | |
| virtual unsigned | descriptor () const |
| Get the socket's descriptor. | |
| virtual bool | setSocket (const DtInetEndpoint &dest, DtU16 localPort=0, DtInetDevice *hostIf=NULL, DtU32 flags=DtDefaultSockOpts) |
| Set all socket parameters at once. | |
| virtual void * | udpSocket () |
| Return the underlying socket object. | |
| virtual void * | secondUdpSocket () |
| Return the second underlying socket object. | |
| virtual DtInetSockRcvStatus | recv (caddr_t buff, size_t buffSize, DtU32 flags=0) |
| Simple receive method. | |
| virtual DtInetSockRcvStatus | recvToChain (DtInetBufferChain &packets, DtU32 flags=0) |
| Receives into a buffer chain. | |
| virtual DtInetSockRcvStatus | recvToChainFrom (DtInetBufferChain &packets, DtInetEndpoint &src, DtU32 flags=0) |
| Simple receive method. | |
| virtual bool | setMcastDevice (const DtInetAddr &devAddr) |
| virtual bool | setMcastDevice (DtInetDevice *hostIf) |
| virtual DtU32 | getSendBufferSize () |
| virtual DtU32 | getReceiveBufferSize () |
| virtual DtU32 | getBytesAvailable () |
| virtual bool | getBroadcastOption () |
| virtual bool | getReuseAddressOption () |
| virtual bool | getDoNotRouteOption () |
| virtual DtU32 | getSendLowWatermark () |
| virtual DtU32 | getReceiveLowWatermark () |
| virtual bool | joinMulticastGroup (const DtInetAddr &grpAddr, DtInetDevice *device=NULL) |
| Change the default time-to-live on outbound multicast packets sent from this socket. | |
| virtual bool | joinMulticastGroup (const DtInetEndpoint &grpEndpoint, DtInetDevice *device=NULL) |
| Change the default time-to-live on outbound multicast packets sent from this socket. | |
| virtual bool | dropMulticastGroup (const DtInetAddr &grpAddr, DtInetDevice *device=NULL) |
| Change the default time-to-live on outbound multicast packets sent from this socket. | |
| virtual bool | dropMulticastGroup (const DtInetEndpoint &grpEndpoint, DtInetDevice *device=NULL) |
| Change the default time-to-live on outbound multicast packets sent from this socket. | |
Public Member Functions inherited from DtInetSocket | |
| DtInetSocket () | |
| Default Constructor. | |
| virtual | ~DtInetSocket () |
| Destructor. | |
| virtual const DtInetEndpoint & | destination () const |
| virtual const DtInetEndpoint & | localEndpoint () const |
| Get the local endpoint for the socket. | |
| virtual bool | setLocalPort (DtU16 port) |
| Set / get the local port number of the socket. | |
| virtual DtU16 | localPort () const |
| virtual const DtInetDevice * | hostIf () const |
| Get the host network interface device the socket is bound to. | |
| virtual DtInetSockState | state () |
| Return the present state of the socket. | |
| virtual DtU32 | protocol () const |
| Get the protocol (DtInetProtocol_TCP or DtInetProtocol_UDP) | |
| virtual DtInetUtils::DtInetAddrFamily | family () const |
| Get the address family, IPv4 or IPv6. | |
| virtual DtU32 | flags () |
| Get the flags for this socket. | |
| virtual int | getLastError () |
| Return code or string describing last error. | |
| virtual DtString | getLastErrorString () |
| virtual bool | isErrorWouldBlockOrTryAgain () |
| virtual void | clearError () |
| virtual int | getTerminationCode () |
| Return code or string describing termination cause. | |
| virtual DtString | getTerminationString () |
| virtual DtU64 | totalBytesSent () const |
| Get traffic statistics. | |
| virtual DtU64 | totalPacketsSent () const |
| virtual DtU64 | totalBytesReceived () const |
| virtual DtU64 | totalPacketsReceived () const |
| virtual void | clearStats () |
| Reset all statistics. | |
| virtual bool | addProcessingCallback (DtInetSockProcessingType kind, DtInetSocketProcessingCallback cb, void *usr, int callSequence=-1) |
| Add / remove pre- and post- processing callbacks. | |
| virtual bool | removeProcessingCallback (DtInetSockProcessingType kind, DtInetSocketProcessingCallback cb) |
| virtual DtTime | receiveTime () |
| virtual bool | isNonBlocking () const |
| virtual bool | isNoDelay () const |
| virtual bool | isIPv4 () const |
| Return true if the socket matches the queried family or protocol. | |
| virtual bool | isIPv6 () const |
| Return true if the socket matches the queried family or protocol. | |
| virtual bool | isTcp () const |
| Return true if the socket matches the queried family or protocol. | |
| virtual bool | isUdp () const |
| Return true if the socket matches the queried family or protocol. | |
Protected Member Functions | |
| virtual void * | disSendSocket () |
| Return the underlying Boost class socket objects. | |
| virtual DtU16 | getPduSize (DtDisSocketPduHeader *hdr, int hdrOffset, DtInetBufferChain::iterator current, DtInetBufferChain::iterator end, int *status, bool &isCoupling, bool expectAttributePdu=false) |
| virtual DtU16 | getCoupledAttributePduSize (DtDisSocketPduHeader *hdr, int hdrOffset, DtInetBufferChain::iterator current, DtInetBufferChain::iterator end, int *status, int pduLengthAndPadding, unsigned int size) |
| virtual DtInetBufferChain::iterator | advanceToOffset (DtU16 &offset, DtInetBufferChain::iterator chainIter, DtInetBufferChain::iterator chainEnd) |
Static Protected Member Functions | |
| static int | suppressSelfReflect (DtInetSocket *sock, int size, DtInetBufferChain &buffChain, DtInetEndpoint &ep, void *usr) |
| Suppress self-reflection callback. | |
| static int | filterExercisePdus (DtInetSocket *sock, int size, DtInetBufferChain &buffChain, DtInetEndpoint &ep, void *usr) |
| PDU filtering callback. | |
| static int | minSizeFilter (DtInetSocket *sock, int size, DtInetBufferChain &buffChain, DtInetEndpoint &ep, void *usr) |
| Filter PDUs that are smaller than size of DIS PDU header. | |
Bundling callbacks. | |
All pre- and post- processing callbacks must return the total number of bytes in buffChain after processing or a negative value if an error occurs. The static methods are registered as callbacks, but the actual work takes place in the bundling methods. | |
| static int | addToBundle (DtInetSocket *sock, int size, DtInetBufferChain &buffChain, DtInetEndpoint &ep, void *usr) |
| static int | flushBundle (DtInetSocket *sock, int size, DtInetBufferChain &buffChain, DtInetEndpoint &ep, void *usr) |
| static int | unbundle (DtInetSocket *sock, int size, DtInetBufferChain &buffChain, DtInetEndpoint &ep, void *usr) |
| static int | getNextBundle (DtInetSocket *sock, int size, DtInetBufferChain &buffChain, DtInetEndpoint &ep, void *usr) |
Private Member Functions | |
| DtDisSocket (const DtDisSocket &orig) | |
| Copy constructor not implemented. | |
| DtDisSocket & | operator= (const DtDisSocket &orig) |
| Assignment not implemented. | |
Private Attributes | |
| DtDisSockPimpl * | myAsyncSendSockPimpl |
Friends | |
| class | DtDisSockPimpl |
| For async operations. | |
Additional Inherited Members | |
Protected Types inherited from DtInetUdpSocket | |
| typedef std::pair< DtInetAddr, DtInetAddr > | DtInetMcastGroupIntfcBinding |
| Associate the multicast group address with the host interface address the group is joined from. | |
| typedef std::vector < DtInetMcastGroupIntfcBinding > | DtInetMcastGroupBindings |
The DtDisSocket class provides an address family independent datagram socket.
| DtDisSocket::DtDisSocket | ( | const DtInetEndpoint & | dest, |
| DtU16 | localPort = 0, |
||
| DtInetDevice * | hostIf = NULL, |
||
| DtU32 | flags = DtDefaultSockOpts, |
||
| bool | immediateOpen = true, |
||
| bool | suppressSelfReflectEnabled = false |
||
| ) |
DIS Socket Constructor.
Takes a destination endpoint, a source port to use, a pointer to the local network interface device the socket will be bound to, socket option flags, an 'immediateOpen' indicator dictating how the socket should behave upon creation, and a flag to enable self- reflect suppression. If the destination endpoint port is 0 the default DIS port (3000) will be used. The address family (IPv4 or IPv6) is assumed from the destination endpoint object. If suppressSelfReflect is true all packets will be sent from the specified local port or an automatically chosen ephemeral if the localPort parameter is 0. If no host interface is specified the most appropriate interface will be chosen based on the destination. If the destination endpoint specifies a multicast address the multicast group is joined automatically when the socket is opened and the group membership is dropped when the socket is closed. If the 'immediateOpen' parameter is true the socket will immediately try to bind to an interface and allow datagrams to be sent and received. To use custom packet handlers for the send and receive functions the handlers must be set before any call to any of the send and receive methods. To ensure the handlers are configured it is recommended that 'immediateOpen' be set to false so the packet handler callbacks can be configured, then call openSocket(). This ctor will not throw exceptions on failure. Check the socket status by calling state() (or isOk()) to determine if the socket is ready.
|
virtual |
Destructor.
|
private |
Copy constructor not implemented.
|
virtual |
Add an additional destination.
Packets will be sent to these destinations in addition to the sockets destination. Return indicates if destination was added successfully (true) or not (false).
|
virtual |
|
staticprotected |
|
protectedvirtual |
|
virtual |
|
virtual |
Close a socket.
Returns true on successful close or false on failure. Call getLastError() and getLastErrorString() to retrieve cause of failure. The base class method is overridden to provide the optional capability to filter self-reflects by sending PDUs from a different socket on an ephemeral port
Reimplemented from DtInetUdpSocket.
|
protectedvirtual |
Return the underlying Boost class socket objects.
|
inlinevirtual |
DIS PDU filtering extension interface.
|
virtual |
Filter out PDUs which match the parameters configured in the DtPduFilterTests.
|
staticprotected |
PDU filtering callback.
This should always be added to the callbacks. The individual filtering tests can be enabled / disabled on the fly.
|
virtual |
Flush bundles. This method is called to flush all queued bundles.
|
virtual |
|
staticprotected |
|
protectedvirtual |
|
virtual |
|
virtual |
|
staticprotected |
|
protectedvirtual |
|
inlinevirtual |
|
virtual |
|
virtual |
Return the endpoint of the sender.
This will differ from the receiving endpoint when self-reflect suppression is enabled.
|
virtual |
|
virtual |
Filter PDUs that are smaller than size of DIS PDU header.
|
staticprotected |
Filter PDUs that are smaller than size of DIS PDU header.
|
virtual |
Enable sending and receiving of packets.
Returns true on success or false on failure. Call getLastError() and getLastErrorString() to retrieve cause of failure. The base class method is overridden to provide the optional capability to filter self-reflects by sending PDUs from a different socket on an ephemeral port
Reimplemented from DtInetUdpSocket.
|
private |
Assignment not implemented.
|
inlinevirtual |
|
inlinevirtual |
|
virtual |
|
virtual |
Receive method override The DtInetUdpSocket base class revcFrom() method does not perform unbundling, PDU filtering, or self-reflect suppression.
For backward compatibility those additional tasks are supported in all DIS socket receive methods.
Reimplemented from DtInetUdpSocket.
|
virtual |
Remove a destination.
Address will be removed from the list of additional destinations for sending packets.
|
virtual |
Sends only to the given destination.
Reimplemented from DtInetUdpSocket.
|
virtual |
|
virtual |
Sends only to the given destination.
Reimplemented from DtInetUdpSocket.
|
virtual |
Sends only to the given destination.
Reimplemented from DtInetUdpSocket.
|
virtual |
|
virtual |
|
virtual |
|
virtual |
|
virtual |
Sends only to the given destination.
Reimplemented from DtInetUdpSocket.
|
virtual |
Sets/Gets whether to parse for coupled attribute PDU.
Reimplemented from DtInetUdpSocket.
|
virtual |
|
virtual |
Bundling is only performed when using the sendChain(), sendChainTo(), recvToChain(), and recvToChainFrom() methods.
If maxBundleSize == 0 bundling is disabled. Unbundling is always enabled. Deprecated. Provided for backwards compatibility.
Set all bundling parameters at once. The sizeOffset, sizeLength, and testDisHeader arguments are ignored.
Reimplemented from DtInetUdpSocket.
|
virtual |
Change the default time-to-live on outbound multicast packets sent from this socket.
Reimplemented from DtInetUdpSocket.
|
virtual |
Reimplemented from DtInetUdpSocket.
Reimplemented from DtInetUdpSocket.
Reimplemented from DtInetUdpSocket.
Reimplemented from DtInetUdpSocket.
Reimplemented from DtInetUdpSocket.
Reimplemented from DtInetUdpSocket.
|
virtual |
|
virtual |
Supress self-reflection method.
Filters out PDUs which originated from this socket's send port.
|
staticprotected |
Suppress self-reflection callback.
The real work is done by the public suppressSelfReflect method
|
virtual |
|
staticprotected |
|
friend |
For async operations.
|
protected |
|
protected |
|
private |
|
protected |
|
protected |
|
protected |
|
protected |
|
protected |
|
protected |
|
protected |
|
protected |
|
protected |
|
protected |
|
protected |
Using Void pointer to abstract a boost type actual type: boost::asio::ip::udp::socket*.
|
protected |
Using Void pointer to abstract a boost type actual type: boost::asio::io_service*.
|
protected |
|
protected |
|
protected |