FARGOS/VISTA Object Management Environment Core  ..
FARGOS/VISTA Object Management Environment Core Table of Contents
GenericSocketAddress Class Reference

Protocol-independent representation of a socket address. IPv4, IPv6 and file domain sockets are supported. More...

#include <HTTPembeddedServer.hpp>

Classes

union  GenericSocketAddress_union
 

Public Member Functions

int setFromHostAndPort (const char *targetAddress, uint16_t port)
 Assign from an URL representation of the address and an integer value of the port. The following URL prefixes are recognized: "ipv4:", "ipv6:" and "file:". If no prefix is specified, the default of "ipv4:" is assumed. More...
 
int setFromURL (const char *addressString)
 Convenience cover to setFromHostAndPort() that also converts the port. More...
 
 GenericSocketAddress () OME_ALWAYS_INLINE
 
 GenericSocketAddress (const struct sockaddr_in ipv4) OME_ALWAYS_INLINE
 
 GenericSocketAddress (const struct sockaddr_in6 ipv6) OME_ALWAYS_INLINE
 
 GenericSocketAddress (const char *addressString)
 
 GenericSocketAddress (const struct sockaddr *generic_addr, socklen_t addrLen) OME_ALWAYS_INLINE
 
 GenericSocketAddress (const char *address, uint16_t port)
 
 GenericSocketAddress (const std::string &address, uint16_t port)
 
GenericSocketAddressoperator= (const struct sockaddr_in ipv4) OME_ALWAYS_INLINE
 
GenericSocketAddressoperator= (const struct sockaddr_in6 ipv6) OME_ALWAYS_INLINE
 
int copyAddressAndPort (char *addrText, uint32_t bfrSize, bool includeURLprefix=false) const
 Return the address as a URL. More...
 
char * getAddressAndPort (char *bfr, uint32_t bfrSize, bool includeURLprefix=false) const
 Convenience cover to copyAddressAndPort() that concatenates the port to the result. More...
 
bool operator== (const GenericSocketAddress &arg) const OME_ALWAYS_INLINE
 
bool operator!= (const GenericSocketAddress &arg) const OME_ALWAYS_INLINE
 
bool operator< (const GenericSocketAddress &arg) const OME_ALWAYS_INLINE
 
bool operator> (const GenericSocketAddress &arg) const OME_ALWAYS_INLINE
 

Public Attributes

union GenericSocketAddress::GenericSocketAddress_union socketAddress
 
uint8_t addressLength
 

Detailed Description

Protocol-independent representation of a socket address. IPv4, IPv6 and file domain sockets are supported.

Constructor & Destructor Documentation

◆ GenericSocketAddress() [1/7]

GenericSocketAddress::GenericSocketAddress ( )
inline

References addressLength.

◆ GenericSocketAddress() [2/7]

GenericSocketAddress::GenericSocketAddress ( const struct sockaddr_in  ipv4)
inlineexplicit

◆ GenericSocketAddress() [3/7]

GenericSocketAddress::GenericSocketAddress ( const struct sockaddr_in6  ipv6)
inlineexplicit

◆ GenericSocketAddress() [4/7]

GenericSocketAddress::GenericSocketAddress ( const char *  addressString)
inlineexplicit

References setFromURL().

◆ GenericSocketAddress() [5/7]

GenericSocketAddress::GenericSocketAddress ( const struct sockaddr *  generic_addr,
socklen_t  addrLen 
)
inlineexplicit

◆ GenericSocketAddress() [6/7]

GenericSocketAddress::GenericSocketAddress ( const char *  address,
uint16_t  port 
)
inline

References setFromHostAndPort().

◆ GenericSocketAddress() [7/7]

GenericSocketAddress::GenericSocketAddress ( const std::string &  address,
uint16_t  port 
)
inline

References setFromHostAndPort().

Member Function Documentation

◆ copyAddressAndPort()

int GenericSocketAddress::copyAddressAndPort ( char *  addrText,
uint32_t  bfrSize,
bool  includeURLprefix = false 
) const
inline

Return the address as a URL.

Parameters
addrTextpoints to the buffer into which the textual representation of the address will be constructed.
bfrSizespecifies the size of the buffer.
includeURLprefixis a Boolean that indicates if a type-specific URL prefix, such as "ipv4://", should be included before the address.
Returns
The port will be returned as the integer result.

References GenericSocketAddress::GenericSocketAddress_union::filename, GenericSocketAddress::GenericSocketAddress_union::genericAddr, GenericSocketAddress::GenericSocketAddress_union::ipv4, GenericSocketAddress::GenericSocketAddress_union::ipv6, ntohs, safe_strcpy, and socketAddress.

Referenced by getAddressAndPort().

◆ getAddressAndPort()

char* GenericSocketAddress::getAddressAndPort ( char *  bfr,
uint32_t  bfrSize,
bool  includeURLprefix = false 
) const
inline

Convenience cover to copyAddressAndPort() that concatenates the port to the result.

Parameters
bfrpoints to the buffer into which the textual representation of the address and port will be constructed.
bfrSizespecifies the size of the buffer.
includeURLprefixis a Boolean that indicates if a type-specific URL prefix, such as "ipv4://", should be included before the address.
Returns
A pointer to the result string is returned.

References copyAddressAndPort().

◆ operator!=()

bool GenericSocketAddress::operator!= ( const GenericSocketAddress arg) const
inline

◆ operator<()

bool GenericSocketAddress::operator< ( const GenericSocketAddress arg) const
inline

◆ operator=() [1/2]

GenericSocketAddress& GenericSocketAddress::operator= ( const struct sockaddr_in  ipv4)
inline

◆ operator=() [2/2]

GenericSocketAddress& GenericSocketAddress::operator= ( const struct sockaddr_in6  ipv6)
inline

◆ operator==()

bool GenericSocketAddress::operator== ( const GenericSocketAddress arg) const
inline

◆ operator>()

bool GenericSocketAddress::operator> ( const GenericSocketAddress arg) const
inline

◆ setFromHostAndPort()

int GenericSocketAddress::setFromHostAndPort ( const char *  targetAddress,
uint16_t  port 
)
inline

Assign from an URL representation of the address and an integer value of the port. The following URL prefixes are recognized: "ipv4:", "ipv6:" and "file:". If no prefix is specified, the default of "ipv4:" is assumed.

Parameters
targetAddresspoints to a string containing the text representation of the address, which may be prefixed with the relevant type. For IPv4 addresses, this is expected to be a dotted-decimal string. For IPv6 addresses, this is expected to be a colon-separated string of hexadecimal values. For files, this is expected to be a path.
portspecifies the port.

Use setFromURL() if the address text also contains the port.

References addressLength, GenericSocketAddress::GenericSocketAddress_union::filename, htons, GenericSocketAddress::GenericSocketAddress_union::ipv4, GenericSocketAddress::GenericSocketAddress_union::ipv6, l, and socketAddress.

Referenced by GenericSocketAddress(), and setFromURL().

◆ setFromURL()

int GenericSocketAddress::setFromURL ( const char *  addressString)
inline

Convenience cover to setFromHostAndPort() that also converts the port.

Parameters
addressStringpoints to the text string to be parsed and converted.

References setFromHostAndPort(), and text2uint32().

Referenced by GenericSocketAddress().

Member Data Documentation

◆ addressLength

◆ socketAddress


The documentation for this class was generated from the following file:
Generated: Tue Jul 28 2020 16:03:27
Support Information