BYTEORDER(3N) RISC/os Reference Manual BYTEORDER(3N)
NAME
byteorder: htonl, htons, ntohl, ntohs - convert values
between host and network byte order
SYNOPSIS
Headers
For -systype sysv:
#include <sys/types.h>
#include <bsd/netinet/in.h>
For -systype bsd43:
#include <sys/types.h>
#include <netinet/in.h>
Declarations
netlong = htonl(hostlong);
ulong netlong, hostlong;
netshort = htons(hostshort);
ushort netshort, hostshort;
hostlong = ntohl(netlong);
ulong hostlong, netlong;
hostshort = ntohs(netshort);
ushort hostshort, netshort;
DESCRIPTION
These routines convert 16 and 32 bit quantities between net-
work byte order and host byte order. These routines are
defined as null macros in the include file
<bsd/netinet/in.h> for -systype sysv and in <netinet/in.h>
for -systype bsd43.
These routines are most often used in conjunction with
Internet addresses and ports as returned by
gethostbyname(3N) and getservent(3N).
SEE ALSO
gethostbyname(3N), getservent(3N).
NOTE
When these routines are used in a program which is compiled
in -systype sysv, they are not resolved by libc.a. See
intro(3-SysV) for more information.
Printed 1/15/91 Page 1