NE_IADDR_MAKE(3)
π NE_IADDR_MAKE(3) β like, the whole network-address friend group
okay so this is the neon API reference page for NE_IADDR_MAKE(3) and bestie, it's literally a whole squad of functions for messing with network addresses. no cap, they're all here. π¦
β¨ NAME β¨
ne_iaddr_make, ne_iaddr_cmp, ne_iaddr_print, ne_iaddr_typeof, ne_iaddr_parse, ne_iaddr_raw, ne_iaddr_put, ne_iaddr_reverse, ne_iaddr_free β functions to manipulate network addresses. that's the whole friend group, they all serve π
πΈ SYNOPSIS πΈ
#include <ne_socket.h>
typedef enum {
ne_iaddr_ipv4 = 0,
ne_iaddr_ipv6
} ne_iaddr_type;
ne_inet_addr *ne_iaddr_make(ne_iaddr_type type,
const unsigned char *raw);
int ne_iaddr_cmp(const ne_inet_addr *ia1, const ne_inet_addr *ia2);
char *ne_iaddr_print(const ne_inet_addr *ia, char *buffer,
size_t bufsiz);
ne_iaddr_type ne_iaddr_typeof(const ne_inet_addr *ia);
ne_inet_addr *ne_iaddr_parse(const char *address, ne_iaddr_type type);
unsigned char *ne_iaddr_raw(const ne_inet_addr *ia,
unsigned char *buffer);
ne_inet_addr *ne_iaddr_put(ne_inet_addr *ia, ne_iaddr_type type,
const unsigned char *raw);
int ne_iaddr_reverse(const ne_inet_addr *ia, char *buffer,
size_t buflen);
void ne_iaddr_free(ne_inet_addr *ia);
π DESCRIPTION π
okay so let's go through them one by one, because each one is kinda iconic in its own way.
ne_iaddr_make creates an ne_inet_addr object from a raw binary network address. like, for instance the four bytes 0x7f 0x00 0x00 0x01 represent the IPv4 address 127.0.0.1 β¨ the object returned is suitable for passing to ne_sock_connect. a binary IPv4 address contains four bytes; a binary IPv6 address contains sixteen bytes; addresses passed must be in network byte order. (yes, byte order matters, don't come for me π)
ne_iaddr_cmp compares two network address objects, returning zero only if they are identical. and here's the cute part β the objects don't even need to have the same address type! but if the addresses aren't the same type, the return value is guaranteed to be non-zero. so no fake-matching across types, periodt π
ne_iaddr_print prints a human-readable string representation of a network address into a buffer. think, like, the string "127.0.0.1". it's giving "make it readable for the rest of us" π«Ά
ne_iaddr_typeof returns the type of the given network address object. simple, clean, does exactly what it says on the tin.
ne_iaddr_put changes an existing network address object to a new raw byte representation given by parameter type β and yes, that type can be different to the current type of the object, glow-up included π the raw data must be of length 4 bytes for an IPv4 address, or 16 bytes for an IPv6 address. don't get the lengths wrong or it's gonna be a whole thing.
ne_iaddr_parse parses a string representation of a network address (such as "127.0.0.1") and creates a network address object to represent the parsed address. string in, object out, slay β¨
ne_iaddr_raw writes the raw byte representation of a network address to the provided buffer. the bytes are written in network byte order; the buffer must be of suitable length for the type of address (4 bytes for an IPv4 address, 16 bytes for an IPv6 address). lowkey the inverse of ne_iaddr_make, iykyk.
ne_iaddr_reverse performs a reverse name lookup on the address object, writing the (first) hostname associated with the IP address to the provided buffer. important though: if the hostname is longer than the buffer it will be silently truncated π but on success the string written to the buffer is always NUL-terminated, so at least it's safely closed off.
ne_iaddr_free releases the memory associated with a network address object. bestie please call this, we don't leak in this house π§
β RETURN VALUE β
ne_iaddr_makereturnsNULLif the address type passed is not supported (for instance on a platform which does not support IPv6).ne_iaddr_printreturns the buffer pointer, and neverNULL. never ever, fr fr.ne_iaddr_parsereturns a network address object on success, orNULLon failure to parse theaddressparameter.ne_iaddr_reversereturns zero on success or non-zero if no hostname is associated with the address.ne_iaddr_rawreturns the buffer parameter, and neverNULL.ne_iaddr_putreturns the passed iniaparameter, orNULLif the address type passed is not supported (for instance on a platform which does not support IPv6).
π EXAMPLES π
the following example connects a socket to port 80 at the address 127.0.0.1. it's a little main character moment, honestly π
unsigned char addr[] = "\0x7f\0x00\0x00\0x01";
ne_inet_addr *ia;
ia = ne_iaddr_make(ne_iaddr_ipv4, addr);
if (ia != NULL) {
ne_socket *sock = ne_sock_connect(ia, 80);
ne_iaddr_free(ia);
/* ... */
} else {
/* ... */
}
π¦ HISTORY π¦
some of these are newer than others, timeline check:
- the
ne_iaddr_rawfunction is available in neon0.29.0and later. - the
ne_iaddr_putfunction is available in neon0.37.0and later.
π SEE ALSO π
ne_addr_resolve(3)β go read that one too, bestie π«Ά
π COPYRIGHT π
Copyright Β© 2001-2026 Joe Orton
that's the whole page, no skips, no summaries. everything's in there. π―
and finally, the cute sign-off: this was neon, dated 03/20/2026, and you just read NE_IADDR_MAKE(3). love that for us πβ¨π
π¦ where this page comes from
- arch rolling: neon 0.37.1-1 Β· LGPL-2.0-or-later
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash-1017 on : a language model's rewrite of the original, under its terms