The manual
ginnOS
The reference: libc, the libraries and the kernel
Loading...
Searching...
No Matches
inet.h File Reference

IPv4 addresses as text ("10.0.2.15") and back. More...

#include <netinet/in.h>

Go to the source code of this file.

Functions

int inet_pton (int af, const char *src, void *dst)
 text to an address.
const char * inet_ntop (int af, const void *src, char *dst, socklen_t size)
 an address to text.
in_addr_t inet_addr (const char *text)
 text to an address, as inet_aton does; the address, or INADDR_NONE.
int inet_aton (const char *text, struct in_addr *out)
 text to an address.
char * inet_ntoa (struct in_addr in)
 an address to text, in a buffer of the calling thread.

Detailed Description

IPv4 addresses as text ("10.0.2.15") and back.

Function Documentation

◆ inet_pton()

int inet_pton ( int af,
const char * src,
void * dst )

text to an address.

Parameters
afAF_INET.
dstreceives a struct in_addr.
Returns
1, 0 if src is not an address, -1 (EAFNOSUPPORT) for another af.

◆ inet_ntop()

const char * inet_ntop ( int af,
const void * src,
char * dst,
socklen_t size )

an address to text.

Parameters
sizeat least INET_ADDRSTRLEN for AF_INET.
Returns
dst, or NULL (EAFNOSUPPORT, ENOSPC).

◆ inet_addr()

in_addr_t inet_addr ( const char * text)

text to an address, as inet_aton does; the address, or INADDR_NONE.

◆ inet_aton()

int inet_aton ( const char * text,
struct in_addr * out )

text to an address.

as well as a.b.c.d this takes the older forms: a.b.c (c is 16 bits), a.b (b is 24 bits) and a (32 bits), each part in decimal, octal (0) or hex (0x).

Returns
1, or 0 if text is not an address.

◆ inet_ntoa()

char * inet_ntoa ( struct in_addr in)

an address to text, in a buffer of the calling thread.