.\" Copyright (c) 1983, 1991, 1993 .\" The Regents of the University of California. All rights reserved. .\" .\" %sccs.include.redist.man% .\" .\" @(#)byteorder.3 8.1 (Berkeley) 06/04/93 .\" .Dd .Dt BYTEORDER 3 .Os BSD 4.2 .Sh NAME .Nm htonl , .Nm htons , .Nm ntohl , .Nm ntohs .Nd convert values between host and network byte order .Sh SYNOPSIS .Fd #include .Ft u_long .Fn htonl "u_long hostlong" .Ft u_short .Fn htons "u_short hostshort" .Ft u_long .Fn ntohl "u_long netlong" .Ft u_short .Fn ntohs "u_short netshort" .Sh DESCRIPTION These routines convert 16 and 32 bit quantities between network byte order and host byte order. On machines which have a byte order which is the same as the network order, routines are defined as null macros. .Pp These routines are most often used in conjunction with Internet addresses and ports as returned by .Xr gethostbyname 3 and .Xr getservent 3 . .Sh SEE ALSO .Xr gethostbyname 3 , .Xr getservent 3 .Sh HISTORY The .Nm byteorder functions appeared in .Bx 4.2 . .Sh BUGS On the .Tn VAX bytes are handled backwards from most everyone else in the world. This is not expected to be fixed in the near future.