Internet name resolution, socket and connection handling. More...
Macros | |
#define | MAIN_ERR_PREFIX "INET: " |
Message prefix for INET module. | |
Functions | |
int | inet_connect (int *sd, int *af, const char *host, const char *service) |
Establish stream oriented connection. More... | |
int | inet_set_rx_timeout (int sd, unsigned int rx_to) |
Try to set RX timeout for socket. More... | |
int | inet_set_tx_timeout (int sd, unsigned int tx_to) |
Try to set TX timeout for socket. More... | |
void | inet_close (int *sd) |
Close connection and destroy socket. More... | |
Variables | |
int | inet_force_ipv4 |
int | inet_force_ipv4 = 0 |
Error codes | |
#define | INET_ERR_UNSPEC -1 |
Unspecified error. | |
#define | INET_ERR_HNR -2 |
Host name resolution failed. | |
#define | INET_ERR_SNR -3 |
Service name resolution failed. | |
#define | INET_ERR_AF -4 |
Address family not supported. | |
#define | INET_ERR_SOCK -5 |
Socket creation/configuration failed. | |
#define | INET_ERR_CONN -6 |
Connection failed. | |
#define | INET_ERR_BADF -7 |
Invalid socket descriptor. | |
#define | INET_ERR_RX_TO -8 |
Setting RX timeout failed. | |
#define | INET_ERR_TX_TO -9 |
Setting TX timeout failed. | |
Socket option actions | |
#define | INET_OPTS_CLEAR 0 |
Remove socket options. | |
#define | INET_OPTS_SET 1 |
Add socket options. | |
Internet name resolution, socket and connection handling.
void inet_close | ( | int * | sd | ) |
int inet_connect | ( | int * | sd, |
int * | af, | ||
const char * | host, | ||
const char * | service | ||
) |
Establish stream oriented connection.
[out] | sd | Pointer to socket descriptor |
[in,out] | af | Address family |
[in] | host | Name of host |
[in] | service | Name of service |
On success the socket descriptor of the established connection is written to the location pointed to by sd . If the address family was specified as POSIX_AF_UNSPEC
or was enforced by configuration, it is overwritten with the address family that was used to establish the connection.
On error -1 is written to the location pointed to by sd and the value pointed to by af is unchanged.
INET_ERR_xxx
constants for checks) int inet_set_rx_timeout | ( | int | sd, |
unsigned int | rx_to | ||
) |
Try to set RX timeout for socket.
[in] | sd | Socket descriptor |
[in] | rx_to | RX timeout in seconds (Upper limit: 3600) |
If rx_to is set to zero this means "no timeout" (an existing timeout setting will be removed).
INET_ERR_xxx
constants for checks) Definition at line 419 of file inet.c.
References INET_ERR_BADF, INET_ERR_RX_TO, INET_ERR_UNSPEC, and PRINT_ERROR.
int inet_set_tx_timeout | ( | int | sd, |
unsigned int | tx_to | ||
) |
Try to set TX timeout for socket.
[in] | sd | Socket descriptor |
[in] | tx_to | TX timeout in seconds (Upper limit: 3600) |
If tx_to is set to zero this means "no timeout" (an existing timeout setting will be removed).
INET_ERR_xxx
constants for checks) Definition at line 477 of file inet.c.
References INET_ERR_BADF, INET_ERR_TX_TO, INET_ERR_UNSPEC, and PRINT_ERROR.