Evo C++ Library v0.5.1
Public Member Functions | Public Attributes | Static Public Attributes | List of all members
SocketAddressInfo Struct Reference

#include <evo/impl/sysio_sock.h>

Detailed Description

Resolves socket name/address to socket address info.

Public Member Functions

 SocketAddressInfo (int family=AF_INET)
 Constructor. More...
 
 ~SocketAddressInfo ()
 Destructor. More...
 
Error convert (const char *host)
 Convert host address to one or more socket addresses. More...
 
Error convert (const char *host, ushort port)
 Convert host address to one or more socket addresses. More...
 
Error convert (const SubString &host, ushort port=0)
 Convert host address to one or more socket addresses. More...
 
void free ()
 Free results allocated from resolve() or resolve_address. More...
 
SocketAddressInforeset (int family=AF_INET)
 Reset data. More...
 
Error resolve (const char *host, const char *port=NULL, int flags=AI_NUMERICSERV)
 Resolve or convert host name/address and port to one or more socket addresses. More...
 
Error resolve (const char *host, ushort port, int flags=0)
 Resolve host name/address and port to one or more socket addresses. More...
 
Error resolve (const SubString &host, ushort port=0, int flags=0)
 Resolve or convert host name/address and port to one or more socket addresses. More...
 
SocketAddressInfotcp ()
 Setup for resolving to TCP address. More...
 
SocketAddressInfoudp ()
 Setup for resolving to UDP address. More...
 

Public Attributes

int code
 Internal return code from resolve() More...
 
struct addrinfo hints
 Hints used as input to resolve() More...
 
struct addrinfo * ptr
 Pointer to first address in resolve results. More...
 

Static Public Attributes

static const int NUMERIC = AI_NUMERICHOST | AI_NUMERICHOST
 Flags for numeric host address and port. More...
 

Constructor & Destructor Documentation

◆ SocketAddressInfo()

SocketAddressInfo ( int  family = AF_INET)
inline

Constructor.

Parameters
familyAddress family to use, common values: AF_INET for IPv4, AF_INET6 for IPv6

◆ ~SocketAddressInfo()

~SocketAddressInfo ( )
inline

Destructor.

Member Function Documentation

◆ convert() [1/3]

Error convert ( const char *  host)
inline

Convert host address to one or more socket addresses.

  • This is like resolve() but doesn't call an external service (like DNS) so doesn't block
Parameters
hostHost address to convert/resolve (terminated string)
Returns
ENone for success, ENotFound if host not found, otherwise error code

◆ convert() [2/3]

Error convert ( const char *  host,
ushort  port 
)
inline

Convert host address to one or more socket addresses.

  • This is like resolve() but doesn't call an external service (like DNS) so doesn't block
Parameters
hostHost address to resolve (terminated string)
portPort number to use
Returns
ENone for success, ENotFound if host not found, otherwise error code

◆ convert() [3/3]

Error convert ( const SubString host,
ushort  port = 0 
)
inline

Convert host address to one or more socket addresses.

  • This is like resolve() but doesn't call an external service (like DNS) so doesn't block
Parameters
hostHost address to resolve (terminated string)
portPort number to use, 0 for none
Returns
ENone for success, ENotFound if host not found, otherwise error code

◆ free()

void free ( )
inline

Free results allocated from resolve() or resolve_address.

  • This is called automatically by destructor or next resolve() call

◆ reset()

SocketAddressInfo& reset ( int  family = AF_INET)
inline

Reset data.

Parameters
familyAddress family to use, common values: AF_INET for IPv4, AF_INET6 for IPv6
Returns
This

◆ resolve() [1/3]

Error resolve ( const char *  host,
const char *  port = NULL,
int  flags = AI_NUMERICSERV 
)
inline

Resolve or convert host name/address and port to one or more socket addresses.

  • By default this may block while calling external services like DNS, unless flags disables this
Parameters
hostHost name or address to resolve (terminated string)
portPort number or service name to resolve (terminated string), NULL to skip
flagsFlags, use default or NUMERIC, or see getaddrinfo() for more
Returns
ENone for success, ENotFound if host not found, otherwise error code

◆ resolve() [2/3]

Error resolve ( const char *  host,
ushort  port,
int  flags = 0 
)
inline

Resolve host name/address and port to one or more socket addresses.

  • By default this may block while calling external services (like DNS)
Parameters
hostHost name or address to resolve (terminated string)
portPort number to use
flagsFlags, use default or NUMERIC, or see getaddrinfo() for more
Returns
ENone for success, ENotFound if host not found, otherwise error code

◆ resolve() [3/3]

Error resolve ( const SubString host,
ushort  port = 0,
int  flags = 0 
)
inline

Resolve or convert host name/address and port to one or more socket addresses.

  • By default this may block while calling external services like DNS, unless flags disables this
Parameters
hostHost name or address to resolve
portPort number to use, 0 for none
flagsFlags, use default or NUMERIC, or see getaddrinfo() for more
Returns
ENone for success, ENotFound if host not found, otherwise error code

◆ tcp()

SocketAddressInfo& tcp ( )
inline

Setup for resolving to TCP address.

Returns
This

◆ udp()

SocketAddressInfo& udp ( )
inline

Setup for resolving to UDP address.

Returns
This

Member Data Documentation

◆ code

int code

Internal return code from resolve()

◆ hints

struct addrinfo hints

Hints used as input to resolve()

◆ NUMERIC

const int NUMERIC = AI_NUMERICHOST | AI_NUMERICHOST
static

Flags for numeric host address and port.

◆ ptr

struct addrinfo* ptr

Pointer to first address in resolve results.


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