Data Structures | Macros | Functions
socket_addr.h File Reference

Socket address. More...

Data Structures

struct  vtm_socket_addr
 

Macros

#define VTM_SOCK_ADDR_LOCALHOST   "localhost"
 
#define VTM_SOCK_ADDR_IPV4_LOOPBACK   "127.0.0.1"
 
#define VTM_SOCK_ADDR_IPV4_ANY   "0.0.0.0"
 
#define VTM_SOCK_ADDR_IPV6_LOOPBACK   "::1"
 
#define VTM_SOCK_ADDR_IPV6_ANY   "::"
 
#define VTM_SOCK_ADDR_BUF_LEN   46
 

Functions

VTM_API int vtm_socket_os_addr_build (struct vtm_socket_saddr *saddr, struct vtm_socket_addr *from)
 
VTM_API int vtm_socket_os_addr_convert (struct vtm_socket_saddr *saddr, enum vtm_socket_family *fam, char *host_buf, size_t len, unsigned int *port)
 

Macro Definition Documentation

#define VTM_SOCK_ADDR_LOCALHOST   "localhost"

Localhost constant

#define VTM_SOCK_ADDR_IPV4_LOOPBACK   "127.0.0.1"

IPv4 loopback address

#define VTM_SOCK_ADDR_IPV4_ANY   "0.0.0.0"

IPv4 any address placeholder

#define VTM_SOCK_ADDR_IPV6_LOOPBACK   "::1"

IPv6 loopback address

#define VTM_SOCK_ADDR_IPV6_ANY   "::"

IPv6 any address placeholder

#define VTM_SOCK_ADDR_BUF_LEN   46

Minimum buffer size to hold string representation of an IP address

Function Documentation

VTM_API int vtm_socket_os_addr_build ( struct vtm_socket_saddr saddr,
struct vtm_socket_addr from 
)

Converts a readable address in a platform/os specific representation.

Parameters
[out]saddrthe converted address
fromthe address that should be converted
Returns
VTM_OK if the conversion was successful
VTM_ERROR if an error occured
VTM_API int vtm_socket_os_addr_convert ( struct vtm_socket_saddr saddr,
enum vtm_socket_family fam,
char *  host_buf,
size_t  len,
unsigned int *  port 
)

Convertes a platform specific address representation back to a readable format.

Parameters
saddrthe address that should converted
[out]famthe socket family
[out]host_bufthe buffer where the ip address is stored
lenthe length in bytes of the host buffer
[out]portthe port of the address
Returns
VTM_OK if the conversion was successful
VTM_ERROR if an error occured