'\"macro stdmacro
.if n .pH g3n.byteorder @(#)byteorder	40.5 of 1/29/90
.\" Copyright 1989 AT&T
.\" Copyright (c) 1988 Sun Microsystems, Inc. - All Rights Reserved.
.\"
.nr X
.if \nX=0 .ds x} byteorder 3N "" "\&"
.if \nX=1 .ds x} byteorder 3N ""
.if \nX=2 .ds x} byteorder 3N "" "\&"
.if \nX=3 .ds x} byteorder "" "" "\&"
.TH \*(x}
.SH NAME
\f4byteorder, htonl, htons, ntohl, ntohs\fP \- convert values between host and network byte order
.SH SYNOPSIS
.nf
\f4#include <sys/types.h>\fR
\f4#include <netinet/in.h>\fR
.P
\f4netlong = htonl(hostlong);\fR
\f4u_long netlong, hostlong;\fR
.P
\f4netshort = htons(hostshort);\fR
\f4u_short netshort, hostshort;\fR
.P
\f4hostlong = ntohl(netlong);\fR
\f4u_long hostlong, netlong;\fR
.P
\f4hostshort = ntohs(netshort);\fR
\f4u_short hostshort, netshort;\fR
.fi
.SH DESCRIPTION
.P
These routines convert 16 and 32 bit quantities between network
byte order and host byte order. 
On some architectures these routines are defined as
\s-1NULL\s0
macros in the include file
\f4<netinet/in.h>\fR.
On other architectures,
if their host byte order is different from network byte order,
these routines are functional.
.P
These routines are most often used in conjunction with Internet
addresses and ports as returned by
\f4gethostent\fR(3N)
and
\f4getservent\fR(3N).
.SH "SEE ALSO"
\f4gethostent\fR(3N),
\f4getservent\fR(3N)
