.\"Generated by db2man.xsl. Don't modify this, modify the source.
.de Sh \" Subsection
.br
.if t .Sp
.ne 5
.PP
\fB\\$1\fR
.PP
..
.de Sp \" Vertical space (when we can't use .PP)
.if t .sp .5v
.if n .sp
..
.de Ip \" List item
.br
.ie \\n(.$>=3 .ne \\$3
.el .ne 3
.IP "\\$1" \\$2
..
.TH "NE_IADDR_MAKE" 3 "20 January 2006" "neon 0.25.5" "neon API reference"
.SH NAME
ne_iaddr_make, ne_iaddr_cmp, ne_iaddr_print, ne_iaddr_typeof, ne_iaddr_free \- functions to manipulate and compare network addresses
.SH "SYNOPSIS"
.ad l
.hy 0

#include <ne_socket\&.h>

typedef enum {
    ne_iaddr_ipv4 = 0,
    ne_iaddr_ipv6
} \fBne_iaddr_type\fR;
.sp
.HP 29
ne_inet_addr\ *\fBne_iaddr_make\fR\ (ne_iaddr_type\ \fItype\fR, const\ unsigned\ char\ *\fIraw\fR);
.HP 18
int\ \fBne_iaddr_cmp\fR\ (const\ ne_inet_addr\ *\fIia1\fR, const\ ne_inet_addr\ *\fIia2\fR);
.HP 22
char\ *\fBne_iaddr_print\fR\ (const\ ne_inet_addr\ *\fIia\fR, char\ *\fIbuffer\fR, size_t\ \fIbufsiz\fR);
.HP 31
ne_iaddr_type\ \fBne_iaddr_typeof\fR\ (const\ ne_inet_addr\ *\fIia\fR);
.HP 20
void\ \fBne_iaddr_free\fR\ (const\ ne_inet_addr\ *\fIia\fR);
.ad
.hy

.SH "DESCRIPTION"

.PP
\fBne_iaddr_make\fR creates an \fBne_inet_addr\fR object from a raw binary network address; 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 \fBne_sock_connect\fR\&. A binary IPv4 address contains four bytes; a binary IPv6 address contains sixteen bytes; addresses passed must be in network byte order\&.

.PP
\fBne_iaddr_cmp\fR can be used to compare two network addresses; returning zero only if they are identical\&. The addresses need not be of the same address type; if the addresses are not of the same type, the return value is guaranteed to be non\-zero\&.

.PP
\fBne_iaddr_print\fR can be used to print the human\-readable string representation of a network address into a buffer, for instance the string "127\&.0\&.0\&.1"\&.

.PP
\fBne_iaddr_typeof\fR returns the type of the given network address\&.

.PP
\fBne_iaddr_free\fR releases the memory associated with a network address object\&.

.SH "RETURN VALUE"

.PP
\fBne_iaddr_make\fR returns NULL if the address type passed is not supported (for instance on a platform which does not support IPv6)\&.

.PP
\fBne_iaddr_print\fR returns the \fIbuffer\fR pointer, and never NULL\&.

.SH "EXAMPLES"

.PP
The following example connects a socket to port 80 at the address 127\&.0\&.0\&.1\&.

.nf
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 {
    /* \&.\&.\&. */
}
.fi

.SH "SEE ALSO"

.PP
\fBne_addr_resolve\fR(3)

.SH AUTHOR
Joe Orton <neon@webdav\&.org>.
