VR-Link API Documentation for HLA 1.3
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
List of all members | Public Member Functions | Protected Member Functions | Protected Attributes
DtInetEndpoint Class Reference

The DtInetEndpoint class provides a protocol independant, address family independent mechanism to represent the IP address, port, and protocol of one end of a network socket connection. More...

+ Collaboration diagram for DtInetEndpoint:

Public Member Functions

 DtInetEndpoint ()
 Default Constructor.
 DtInetEndpoint (const DtInetAddr &addr, DtU16 port=0, DtInetProtocol protocol=DtInetProtocol_Unspecified)
 Constructor.
 DtInetEndpoint (DtString &netResLoc, DtU16 port=0, DtInetProtocol protocol=DtInetProtocol_Unspecified, DtInetUtils::DtInetAddrFamily familyHint=DtInetUtils::DtInetAddrFamily_IPv4)
 Constructor.
virtual ~DtInetEndpoint ()
 Destructor.
 DtInetEndpoint (const DtInetEndpoint &orig)
 Copy constructor.
DtInetEndpointoperator= (const DtInetEndpoint &orig)
 Assignment.
virtual void hostLookup (DtString &addr, DtU16 port=0, DtInetUtils::DtInetAddrFamily familyHint=DtInetUtils::DtInetAddrFamily_Both)
 Lookup the endpoint information via DNS.
virtual void setAddress (const DtInetAddr &addr)
 Set / get the address of the endpoint.
virtual const DtInetAddraddress () const
virtual void setPort (DtU16 port)
 Set / get the port number of the endpoint.
virtual DtU16 port () const
virtual void setProtocol (DtInetProtocol protocol)
 Set / get the protocol (DtInetProtocol_TCP or DtInetProtocol_UDP).
virtual DtInetProtocol protocol () const
virtual
DtInetUtils::DtInetAddrFamily 
family () const
 Get the address family, IPv4 or IPv6.
virtual void setEndpoint (DtInetProtocol protocol, const DtInetAddr &addr, DtU16 port)
 Set all endpoint parameters at once.
virtual const DtStringtoDtString (bool showProtocol=false) const
 Return a DtString reporting the address, port, and (optionally) protocol of the endpoint.
virtual bool isOk ()
 Return indication that the endpoint is not in an error state.
virtual DtString getLastErrorString ()
 Return string describing last error and clear error indication.
virtual void * tcpEndpoint ()
 Return the appropriate Boost class endpoint object.
virtual void * udpEndpoint ()
virtual bool isIPv4 () const
 Return true if the endpoint matches the queried family or protocol.
virtual bool isIPv6 () const
 Return true if the endpoint matches the queried family or protocol.
virtual bool isTcp () const
 Return true if the endpoint matches the queried family or protocol.
virtual bool isUdp () const
 Return true if the endpoint matches the queried family or protocol.
virtual int toSockaddr (struct sockaddr_in *s)
 Copy address, port, and family into sockaddr struct in network byte order.
virtual int toSockaddr (struct sockaddr_in6 *s)
 Copy address, port, and family into sockaddr struct in network byte order.

Protected Member Functions

void initEndpoint ()

Protected Attributes

void * myTcpEndpoint
void * myUdpEndpoint
DtInetAddr myAddr
DtU16 myPort
DtInetProtocol myProtocol
bool myError
DtString myLastErrorString
bool myMutableStringsInitialized
 These are mutable so that the string can be initialized only if needed, but may then be stored to avoid future re-initialization.
DtString myMutableShortString
DtString myMutableFullString
DtString myNodeName

Friends

bool operator== (const DtInetEndpoint &ep1, const DtInetEndpoint &ep2)
 Comparison operator.
bool operator!= (const DtInetEndpoint &ep1, const DtInetEndpoint &ep2)
 Comparison operator.
bool operator< (const DtInetEndpoint &ep1, const DtInetEndpoint &ep2)
 Comparison operator.
bool operator> (const DtInetEndpoint &ep1, const DtInetEndpoint &ep2)
 Comparison operator.

Detailed Description

The DtInetEndpoint class provides a protocol independant, address family independent mechanism to represent the IP address, port, and protocol of one end of a network socket connection.

Constructor & Destructor Documentation

DtInetEndpoint::DtInetEndpoint ( )

Default Constructor.

DtInetEndpoint::DtInetEndpoint ( const DtInetAddr addr,
DtU16  port = 0,
DtInetProtocol  protocol = DtInetProtocol_Unspecified 
)

Constructor.

Takes a DtInetAddr representing the address, a protocol identifier, and a port number. Address family is assumed from the addr object. If addr is the ANY address for its family the endpoint will be considered a local endpoint which can be bound to any network interface on the host. If addr specifies the address of one of the local host's assigned IP addresses the endpoint will be a local endpoint which can only be bound to the interface that address is assigned to. The port parameter is optional for local endpoints. If port is not specified an ephemeral port may be selected by the socket this endpoint is associated multicast address the endpoint will be a destination endpoint. The port parameter must be set before a destination endpoint can be assigned to a socket.

DtInetEndpoint::DtInetEndpoint ( DtString netResLoc,
DtU16  port = 0,
DtInetProtocol  protocol = DtInetProtocol_Unspecified,
DtInetUtils::DtInetAddrFamily  familyHint = DtInetUtils::DtInetAddrFamily_IPv4 
)

Constructor.

Takes a DtString representing a network resource locator, a port number, and a protocol identifier, and an address family hint and attempts to resolve the network resource locator to a host IP address. If the network resource locator contains an IPv4 or IPv6 address the endpoint address family is set to match. If the network resource locator specifies a remote hostname a DNS lookup is performed. If the network resource locator contains a port modifier the value in the network res- ource locator overrides the port parameter passed in the argument list. object. If network resource locator resolves to the local host the endpoint will be a local endpoint which can be bound to all interfaces. However if the network resource locator resolves to the device name of an interface on the localhost the endpoint will adopt the appropriate IP address for that interface based on the family hint. The endpoint can only be bound to the interface that address is assigned to. The port parameter is optional for local endpoints. If port is not specified an ephemeral port may be selected by the socket this endpoint is associated address, broadcast address, or multicast address the endpoint will be a destination endpoint. The port parameter must be set before a destination endpoint can be assigned to a socket.

virtual DtInetEndpoint::~DtInetEndpoint ( )
virtual

Destructor.

DtInetEndpoint::DtInetEndpoint ( const DtInetEndpoint orig)

Copy constructor.

Member Function Documentation

virtual const DtInetAddr& DtInetEndpoint::address ( ) const
virtual
virtual DtInetUtils::DtInetAddrFamily DtInetEndpoint::family ( ) const
virtual

Get the address family, IPv4 or IPv6.

virtual DtString DtInetEndpoint::getLastErrorString ( )
virtual

Return string describing last error and clear error indication.

virtual void DtInetEndpoint::hostLookup ( DtString addr,
DtU16  port = 0,
DtInetUtils::DtInetAddrFamily  familyHint = DtInetUtils::DtInetAddrFamily_Both 
)
virtual

Lookup the endpoint information via DNS.

If the protocol has been initialized when hostLookup is called a new Boost endpoint object will be created and any old Boost endpoint object safely destroyed.

void DtInetEndpoint::initEndpoint ( )
protected
virtual bool DtInetEndpoint::isIPv4 ( ) const
virtual

Return true if the endpoint matches the queried family or protocol.

virtual bool DtInetEndpoint::isIPv6 ( ) const
virtual

Return true if the endpoint matches the queried family or protocol.

virtual bool DtInetEndpoint::isOk ( )
virtual

Return indication that the endpoint is not in an error state.

Possible errors include: hostname lookup failed, invalid address

virtual bool DtInetEndpoint::isTcp ( ) const
virtual

Return true if the endpoint matches the queried family or protocol.

virtual bool DtInetEndpoint::isUdp ( ) const
virtual

Return true if the endpoint matches the queried family or protocol.

DtInetEndpoint& DtInetEndpoint::operator= ( const DtInetEndpoint orig)

Assignment.

virtual DtU16 DtInetEndpoint::port ( ) const
virtual
virtual DtInetProtocol DtInetEndpoint::protocol ( ) const
virtual
virtual void DtInetEndpoint::setAddress ( const DtInetAddr addr)
virtual

Set / get the address of the endpoint.

If the protocol has been initialized when setAddress is called a new Boost endpoint object will be created and any old Boost endpoint object safely destroyed.

virtual void DtInetEndpoint::setEndpoint ( DtInetProtocol  protocol,
const DtInetAddr addr,
DtU16  port 
)
virtual

Set all endpoint parameters at once.

A new Boost endpoint object will be created.

virtual void DtInetEndpoint::setPort ( DtU16  port)
virtual

Set / get the port number of the endpoint.

If the protocol and address are initialized when setPort is called a new Boost endpoint object will be created and any old Boost endpoint object safely destroyed.

virtual void DtInetEndpoint::setProtocol ( DtInetProtocol  protocol)
virtual

Set / get the protocol (DtInetProtocol_TCP or DtInetProtocol_UDP).

A new Boost endpoint object will be created whenever setProtocol is invoked and any old Boost endpoint object safely destroyed. Nevertheless it is advised that the address and port are initialized before calling setProtocol.

virtual void* DtInetEndpoint::tcpEndpoint ( )
virtual

Return the appropriate Boost class endpoint object.

virtual const DtString& DtInetEndpoint::toDtString ( bool  showProtocol = false) const
virtual

Return a DtString reporting the address, port, and (optionally) protocol of the endpoint.

The output will resemble one of the following depending upon the family of the address: IPv4: address:port or address:port (TCP | UDP) (address is in dotted decimal notation) IPv6: [address]:port or [address]:port (TCP | UDP) (address is in compact hexadecimal notation, scope included if set)

virtual int DtInetEndpoint::toSockaddr ( struct sockaddr_in *  s)
virtual

Copy address, port, and family into sockaddr struct in network byte order.

Returns 0 on success, -1 on error.

virtual int DtInetEndpoint::toSockaddr ( struct sockaddr_in6 *  s)
virtual

Copy address, port, and family into sockaddr struct in network byte order.

Returns 0 on success, -1 on error.

virtual void* DtInetEndpoint::udpEndpoint ( )
virtual

Friends And Related Function Documentation

bool operator!= ( const DtInetEndpoint ep1,
const DtInetEndpoint ep2 
)
friend

Comparison operator.

bool operator< ( const DtInetEndpoint ep1,
const DtInetEndpoint ep2 
)
friend

Comparison operator.

bool operator== ( const DtInetEndpoint ep1,
const DtInetEndpoint ep2 
)
friend

Comparison operator.

bool operator> ( const DtInetEndpoint ep1,
const DtInetEndpoint ep2 
)
friend

Comparison operator.

Member Data Documentation

DtInetAddr DtInetEndpoint::myAddr
protected
bool DtInetEndpoint::myError
protected
DtString DtInetEndpoint::myLastErrorString
protected
DtString DtInetEndpoint::myMutableFullString
mutableprotected
DtString DtInetEndpoint::myMutableShortString
mutableprotected
bool DtInetEndpoint::myMutableStringsInitialized
mutableprotected

These are mutable so that the string can be initialized only if needed, but may then be stored to avoid future re-initialization.

Saves considerable time when setting new endpoint values.

DtString DtInetEndpoint::myNodeName
protected
DtU16 DtInetEndpoint::myPort
protected
DtInetProtocol DtInetEndpoint::myProtocol
protected
void* DtInetEndpoint::myTcpEndpoint
protected
void* DtInetEndpoint::myUdpEndpoint
protected

The documentation for this class was generated from the following file:

Document ID: Generated on Thu Feb 22 04:26:36 EST 2018 from SVN revision 186468
Copyright © 2005-2016 VT MÄK. All Rights Reserved (www.mak.com)