![]() |
VR-Link API Documentation for HLA Evolved
|
A DtSocket that implements network sending and receiving function using IP/UDP broadcast, multicast or unicast. More...
Inheritance diagram for DtNetSocket:
Collaboration diagram for DtNetSocket:Public Member Functions | |
| DtNetSocket (int port=DtDEFAULT_PORT, DtU8 flags=DtReadWrite, DtIpv4Addr devAddr=0) | |
| Constructor. | |
| DtNetSocket (int port, DtIpv4Addr destAddr, DtU8 flags, DtIpv4Addr devAddr=0) | |
| Constructor. | |
| DtNetSocket (char *dummy, int sockfd, DtU8 flags=DtReadWrite) | |
| Allows you to create a DtNetSocket that uses a pre-existing socket. | |
| virtual | ~DtNetSocket () |
| Destructor. | |
| virtual int | sendTo (caddr_t packet, size_t size, DtIpv4Addr addr) |
| Virtual function override. | |
| virtual int | DtRecv (caddr_t *buffptr, int *status=NULL) |
| DtNetSocket implements DtRecv by calling a system call to recvfrom on its UDP socket. | |
| virtual int | DtRecv (caddr_t buff, size_t) |
| DtNetSocket implements DtRecv by calling a system call to recvfrom on its UDP socket. | |
| virtual DtIpv4Addr | lastSourceInetAddr () |
| Return the IP address of the sender of the last packet we've received. | |
| virtual void | DtBecomeNonBlocking (void) |
| Make the socket non-blocking. | |
| virtual int | readFd () |
| Return read/write file descriptor of the UDP socket being used for sending and receiving. | |
| virtual int | writeFd () |
| virtual bool | isOk () const |
| Returns 1 if the socket's constructor initialization was successful, 0 otherwise. | |
| virtual int | setMcastTtl (int ttl) |
| Set the TTL (time to live) value for multicast packets. | |
| virtual void | setFilterPort (const int &port) |
| virtual void | setSendPort (const int &port) |
Bundling Functions. | |
| virtual void | setBundling (int maxBundleSize, bool enableUnbundling, int minPacketSize, int sizeOffset, int sizeLength, bool testDisHeader) |
| Set all bundling parameters Disables bundling if max. | |
| virtual void | setBundling (int maxBundleSize) |
| Call through to DtSocket::setBundling to prevent compiler warnings. | |
| virtual void | setUnbundling (int onOff) |
| Pass 0 to setUnbundling to turn unbundling off, 1 to turn it on. | |
| virtual int | isUnbundling () |
| Set all bundling parameters Disables bundling if max. | |
Get/Set minimum valid packet size. | |
If not set manually, the min. size is based on DtNetPduHeader for backwards compatibility. Currently used only when Unbundling is enabled | |
| virtual int | minPacketSize () |
| virtual void | setMinPacketSize (int size) |
Get/Set the offset to PacketSize within the packet header. | |
If not set manually, the offset is based on DtNetPduHeader for backwards compatibility. Currently used only when Unbundling is enabled | |
| virtual int | sizeOffset () |
| virtual void | setSizeOffset (int offset) |
Get/Set the length of the PacketSize field within the packet header. | |
If not set manually, the length is based on DtNetPduHeader for backwards compatibility. Currently used only when Unbundling is enabled | |
| virtual int | sizeLength () |
| virtual void | setSizeLength (int length) |
Enable/Disable test of DIS header fields for valid packets within | |
bundles. Must be disabled for non-DIS network sockets if bundling is desired. If not set manually, the test is enabled for backwards compatibility. Currently used only when Unbundling is enabled | |
| virtual bool | testDisHeader () |
| virtual void | enableDisHeaderTest (bool shouldTest) |
Add/drop subscription to a particular multicast address on | |
the specified network interface. | |
| virtual int | listenToMulticastGroup (DtIpv4Addr multicastAddr, DtIpv4Addr netInterface=DtUSE_DEFAULT_IP_ADDR) |
| virtual int | dropMulticastGroup (DtIpv4Addr multicastAddr, DtIpv4Addr netInterface=DtUSE_DEFAULT_IP_ADDR) |
Set/Get device for multicast traffic | |
| virtual void | setMcastDevice (DtIpv4Addr devAddr) |
| virtual DtIpv4Addr | mcastDevice () const |
Public Member Functions inherited from DtSocket | |
| DtSocket () | |
| Default constructor. | |
| virtual | ~DtSocket () |
| Default Destructor. | |
| 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(). | |
| caddr_t | DtRecv () |
| virtual DtFlushStatus | flush () |
| Send buffered messages. | |
| virtual DtFlushStatus | flush (long &byteCount) |
| Send buffered messages. | |
| virtual void | setReceiveBufferSize (int newsize) |
| Change the socket's receive buffer size that the OS uses to collect incoming data from the network. | |
| virtual void | setSendBufferSize (int newsize) |
| Change the socket's send buffer size that the OS uses when writing data to the network. | |
| virtual int | isBundling () |
| virtual int | DtReportPktsRcvd (void) |
| virtual void | notifyMe () |
| virtual DtFilterTest * | exerciseId () |
| virtual DtFilterTest * | protocolVersion () |
| virtual DtFilterTest * | pduKind () |
| virtual DtFilterTest * | ipAddr () |
Static Public Member Functions | |
| static int | isMulticastAddr (DtIpv4Addr addr) |
| Returns 1 if addr is a multicast address, 0 otherwise. | |
| static int | enableBroadcast (int sockfd) |
| Make sockfd capable of broadcasting. | |
| static void | makeNonBlocking (int sockfd) |
| Make sockfd non-blocking. | |
| static int | makeReusable (int sockfd) |
| Make port/address reusable by other sockets. | |
| 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 ) | |
| static DtIpv4Addr | inetBroadcastOfDevice (const char *device=NULL) |
| Obtain information about a device. | |
| 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. | |
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. | |
| static bool | areQuietSockets () |
Static Public Attributes | |
| static DtInitErrorAction | initErrorAction |
Protected Member Functions | |
| void | init (int port, DtIpv4Addr dest_addr, DtU8 flags, DtIpv4Addr devAddr=0) |
| Called from all constructors. | |
| virtual int | dataLeftInCurrentBundle () |
| Is there still data left in the last received packet? | |
| virtual int | retrySendTo (caddr_t packet, size_t size, sockaddr_in &dest) |
| If retry is enabled, retry failed packet send theMaxSendRetries times. | |
| 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. | |
| virtual int | recvFromNet (caddr_t *buffptr) |
| Grabs the next packet from the network, and puts it into myPktBuff. | |
| virtual int | recvWithUnbundling (caddr_t *buffptr) |
| Used by recvWithStatus if unbundling is on. | |
| int | initSocket () |
| Initialize the socket. | |
| int | initWrite (DtIpv4Addr dest) |
| Initialize for writing. | |
| int | initRead (DtIpv4Addr dest) |
| Initialize for reading, including performing bind. | |
| virtual int | privateListenToMulticastGroup (DtIpv4Addr multicastAddr, int on_init=0, DtIpv4Addr netInterface=DtUSE_DEFAULT_IP_ADDR) |
| Helper function for listenToMulticastGroup. | |
| virtual void | findNextPacket () |
| Sets myNextPacket to point to the next packet. | |
| virtual unsigned int | getNextPacketSize () |
| Gets the size of the next packet pointed to by myNextPacket. | |
| virtual unsigned int | currentHeaderMatchesFirstInBundle () |
| DIS-specific function to help decide if unbundling is successful. | |
| DtNetSocket (const DtNetSocket &) | |
| Not Implemented. | |
| DtNetSocket & | operator= (const DtNetSocket &) |
| Not Implemented. | |
Protected Member Functions inherited from DtSocket | |
| virtual bool | accept (char *buf, DtIpv4Addr iaddr) |
Static Protected Member Functions | |
| static ifreq * | findIfr (const char *device, int sock, ifconf *ifc) |
| Find a device. | |
| static DtIpv4Addr | netMaskOfIfr (ifreq *ifr, int sock) |
| Obtain information about a device. Dummy socket needed for ioctls. | |
| 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. | |
Protected Attributes | |
| 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 unsigned int | theMaxSendRetries |
| static double | theSendRetryPeriod |
Static Protected Attributes inherited from DtSocket | |
| static bool | theAreQuietSockets |
| Should a socket print messages, informative or error. | |
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 |
A DtSocket that implements network sending and receiving function using IP/UDP broadcast, multicast or unicast.
The class provides a platform-independent interface to a network connection capable of sending and receiving arbitrary datagrams.
| DtNetSocket::DtNetSocket | ( | int | port = DtDEFAULT_PORT, |
| DtU8 | flags = DtReadWrite, |
||
| DtIpv4Addr | devAddr = 0 |
||
| ) |
Constructor.
Takes a UDP port number, and a flags bitfield. All UDP sockets must use the same port number in order to communicate with each other. A default destination address (address to which is to send outgoing packets) is used - the broadcast address of the host's primary network device.
| DtNetSocket::DtNetSocket | ( | int | port, |
| DtIpv4Addr | destAddr, | ||
| DtU8 | flags, | ||
| DtIpv4Addr | devAddr = 0 |
||
| ) |
Constructor.
Similar to above, but allows you to specify a destination address other than the default broadcast address. destAddr can be a unicast, broadcast or multicast address. A value of 0 for destAddr means use the default broadcast address. The flags argument is required to disambiguate from other constructors.
| DtNetSocket::DtNetSocket | ( | char * | dummy, |
| int | sockfd, | ||
| DtU8 | flags = DtReadWrite |
||
| ) |
Allows you to create a DtNetSocket that uses a pre-existing socket.
Dummy is currently ignored.
|
virtual |
Destructor.
|
protected |
Not Implemented.
|
staticprotected |
|
protectedvirtual |
DIS-specific function to help decide if unbundling is successful.
|
protectedvirtual |
Is there still data left in the last received packet?
|
virtual |
Reimplemented from DtSocket.
|
virtual |
Make the socket non-blocking.
Reimplemented from DtSocket.
|
virtual |
DtNetSocket implements DtRecv by calling a system call to recvfrom on its UDP socket.
Implements DtSocket.
|
virtual |
DtNetSocket implements DtRecv by calling a system call to recvfrom on its UDP socket.
Implements DtSocket.
|
static |
Make sockfd capable of broadcasting.
|
virtual |
|
staticprotected |
Find a device.
If device is NULL, returns the ifreq of the first device capable of broadcast. Dummy socket needed for ioctls.
|
protectedvirtual |
Sets myNextPacket to point to the next packet.
This may or may not require a recvFromNet. Packets less than myMinPktSize bytes long cause the rest of a packet to be discarded, and the following packet is found. If no packets, myNextPacket is set to NULL.
|
static |
|
protectedvirtual |
Gets the size of the next packet pointed to by myNextPacket.
Assumes myNextPacket was set via findNextPacket. Uses sizeLength() and sizeOffset() to determine which bytes represent packet size. Returns 0 if myNextPacket does not point to a valid packet.
|
static |
|
staticprotected |
|
static |
Obtain information about a device.
|
staticprotected |
|
protected |
Called from all constructors.
|
protected |
Initialize for reading, including performing bind.
|
protected |
Initialize the socket.
|
protected |
Initialize for writing.
If dest is 0, use default broadcast address. Actual destination address used is stored in myDestInetAddr.
|
static |
Returns 1 if addr is a multicast address, 0 otherwise.
|
virtual |
Returns 1 if the socket's constructor initialization was successful, 0 otherwise.
Reimplemented from DtSocket.
|
virtual |
Set all bundling parameters Disables bundling if max.
bundle size = 0 (as does base socket setBundling)
|
virtual |
Return the IP address of the sender of the last packet we've received.
Reimplemented from DtSocket.
|
virtual |
Reimplemented from DtSocket.
|
static |
Make sockfd non-blocking.
|
static |
Make port/address reusable by other sockets.
|
virtual |
|
virtual |
|
static |
|
staticprotected |
Obtain information about a device. Dummy socket needed for ioctls.
|
protected |
Not Implemented.
|
protectedvirtual |
Helper function for listenToMulticastGroup.
|
virtual |
Return read/write file descriptor of the UDP socket being used for sending and receiving.
Returns -1 if the socket is not readable/writable.
Reimplemented from DtSocket.
|
protectedvirtual |
Grabs the next packet from the network, and puts it into myPktBuff.
If there is a packet, sets buffptr to point to myPktBuff, and returns size of packet. If not, buffptr = 0, and return 0.
Reimplemented in DtAsyncNetSocket.
|
protectedvirtual |
Sets buffptr to point to the next packet (might be next in bundle, might require a read from net) and returns size.
If no packet, or if the packet is filtered out, buffptr is NULL, and 0 is returned. Status is DtSOCKET_NO_PACKET, DtSOCKET_PACKET, or DtSOCKET_FILTERED_PACKET.
|
protectedvirtual |
Used by recvWithStatus if unbundling is on.
Finds next packet, and sets buffptr to point to it. If no packet, returns 0 and sets buffptr to NULL. Will never return a size larger than the number of remaining bytes in a packet.
|
protectedvirtual |
If retry is enabled, retry failed packet send theMaxSendRetries times.
|
virtual |
Virtual function override.
DtNetSocket implements sendTo by sending the packet to the indicated address through its UDP socket, using the system call sendto.
Implements DtSocket.
Reimplemented in DtAsyncNetSocket.
|
virtual |
Set all bundling parameters Disables bundling if max.
bundle size = 0 (as does base socket setBundling)
|
inlinevirtual |
Call through to DtSocket::setBundling to prevent compiler warnings.
Reimplemented from DtSocket.
References DtSocket::setBundling().
|
virtual |
|
static |
Fill out a sockaddr_in structure.
|
virtual |
Reimplemented from DtSocket.
|
virtual |
Set the TTL (time to live) value for multicast packets.
Reimplemented from DtSocket.
|
virtual |
|
static |
Make socket retry numRetries times ( waiting for waitPeriod between ) when sendto fails ( numRetries = 0 means message will be dropped )
|
virtual |
|
virtual |
|
virtual |
|
virtual |
|
virtual |
|
virtual |
|
virtual |
|
virtual |
Reimplemented from DtSocket.
|
protected |
|
protected |
|
protected |
|
protected |
|
protected |
|
static |
|
protected |
|
protected |
|
protected |
|
protected |
|
protected |
|
protected |
|
protected |
|
protected |
|
protected |
|
protected |
|
protected |
|
protected |
|
protected |
|
protected |
|
protected |
|
protected |
|
protected |
|
protected |
|
protected |
|
protected |
|
protected |
|
staticprotected |
|
staticprotected |