Ethernetwebsoc

Dependencies:   C12832_lcd LM75B WebSocketClient mbed-rtos mbed Socket lwip-eth lwip-sys lwip

Embed: (wiki syntax)

« Back to documentation index

netdb.c File Reference

netdb.c File Reference

API functions for name resolving. More...

Go to the source code of this file.

Functions

struct hostent * lwip_gethostbyname (const char *name)
 Returns an entry containing addresses of address family AF_INET for the host with name name.
int lwip_gethostbyname_r (const char *name, struct hostent *ret, char *buf, size_t buflen, struct hostent **result, int *h_errnop)
 Thread-safe variant of lwip_gethostbyname: instead of using a static buffer, this function takes buffer and errno pointers as arguments and uses these for the result.
void lwip_freeaddrinfo (struct addrinfo *ai)
 Frees one or more addrinfo structures returned by getaddrinfo(), along with any additional storage associated with those structures.
int lwip_getaddrinfo (const char *nodename, const char *servname, const struct addrinfo *hints, struct addrinfo **res)
 Translates the name of a service location (for example, a host name) and/or a service name and returns a set of socket addresses and associated information to be used in creating a socket with which to address the specified service.

Variables

int h_errno
 h_errno is exported in netdb.h for access by applications.

Detailed Description

API functions for name resolving.

Definition in file netdb.c.


Function Documentation

void lwip_freeaddrinfo ( struct addrinfo *  ai )

Frees one or more addrinfo structures returned by getaddrinfo(), along with any additional storage associated with those structures.

If the ai_next field of the structure is not null, the entire list of structures is freed.

Parameters:
aistruct addrinfo to free

Definition at line 235 of file netdb.c.

int lwip_getaddrinfo ( const char *  nodename,
const char *  servname,
const struct addrinfo *  hints,
struct addrinfo **  res 
)

Translates the name of a service location (for example, a host name) and/or a service name and returns a set of socket addresses and associated information to be used in creating a socket with which to address the specified service.

Memory for the result is allocated internally and must be freed by calling lwip_freeaddrinfo()!

Due to a limitation in dns_gethostbyname, only the first address of a host is returned. Also, service names are not supported (only port numbers)!

Parameters:
nodenamedescriptive name or address string of the host (may be NULL -> local address)
servnameport number as string of NULL
hintsstructure containing input values that set socktype and protocol
respointer to a pointer where to store the result (set to NULL on failure)
Returns:
0 on success, non-zero on failure

Definition at line 266 of file netdb.c.

struct hostent* lwip_gethostbyname ( const char *  name ) [read]

Returns an entry containing addresses of address family AF_INET for the host with name name.

Due to dns_gethostbyname limitations, only one address is returned.

Parameters:
namethe hostname to resolve
Returns:
an entry containing addresses of address family AF_INET for the host with name name

Definition at line 85 of file netdb.c.

int lwip_gethostbyname_r ( const char *  name,
struct hostent *  ret,
char *  buf,
size_t  buflen,
struct hostent **  result,
int *  h_errnop 
)

Thread-safe variant of lwip_gethostbyname: instead of using a static buffer, this function takes buffer and errno pointers as arguments and uses these for the result.

Parameters:
namethe hostname to resolve
retpre-allocated struct where to store the result
bufpre-allocated buffer where to store additional data
buflenthe size of buf
resultpointer to a hostent pointer that is set to ret on success and set to zero on error
h_errnoppointer to an int where to store errors (instead of modifying the global h_errno)
Returns:
0 on success, non-zero on error, additional error information is stored in *h_errnop instead of h_errno to be thread-safe

Definition at line 162 of file netdb.c.


Variable Documentation

int h_errno

h_errno is exported in netdb.h for access by applications.

Definition at line 59 of file netdb.c.