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_make returns NULL if the address type passed is not supported (for instance on a platform which does not support IPv6).
  • ne_iaddr_print returns the buffer pointer, and never NULL. never ever, fr fr.
  • ne_iaddr_parse returns a network address object on success, or NULL on failure to parse the address parameter.
  • ne_iaddr_reverse returns zero on success or non-zero if no hostname is associated with the address.
  • ne_iaddr_raw returns the buffer parameter, and never NULL.
  • ne_iaddr_put returns the passed in ia parameter, or NULL if 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_raw function is available in neon 0.29.0 and later.
  • the ne_iaddr_put function is available in neon 0.37.0 and later.

πŸ’œ SEE ALSO πŸ’œ


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