1*48352Scael.\" Copyright (c) 1983, 1991 The Regents of the University of California. 236751Sbostic.\" All rights reserved. 320484Smckusick.\" 443572Strent.\" %sccs.include.redist.man% 520484Smckusick.\" 6*48352Scael.\" @(#)byteorder.3 6.7 (Berkeley) 04/19/91 736751Sbostic.\" 8*48352Scael.Dd 9*48352Scael.Dt BYTEORDER 3 10*48352Scael.Os BSD 4.2 11*48352Scael.Sh NAME 12*48352Scael.Nm htonl , 13*48352Scael.Nm htons , 14*48352Scael.Nm ntohl , 15*48352Scael.Nm ntohs 16*48352Scael.Nd convert values between host and network byte order 17*48352Scael.Sh SYNOPSIS 18*48352Scael.Fd #include <sys/param.h> 19*48352Scael.Ft u_long 20*48352Scael.Fn htonl "u_long hostlong" 21*48352Scael.Ft u_short 22*48352Scael.Fn htons "u_short hostshort" 23*48352Scael.Ft u_long 24*48352Scael.Fn ntohl "u_long netlong" 25*48352Scael.Ft u_short 26*48352Scael.Fn ntohs "u_short netshort" 27*48352Scael.Sh DESCRIPTION 2820484SmckusickThese routines convert 16 and 32 bit quantities between network 2946492Sbosticbyte order and host byte order. 3046492SbosticOn machines which have a byte order which is the same as the network 3146492Sbosticorder, routines are defined as null macros. 32*48352Scael.Pp 3320484SmckusickThese routines are most often used in conjunction with Internet 3420484Smckusickaddresses and ports as returned by 35*48352Scael.Xr gethostbyname 3 3620484Smckusickand 37*48352Scael.Xr getservent 3 . 38*48352Scael.Sh SEE ALSO 39*48352Scael.Xr gethostbyname 3 , 40*48352Scael.Xr getservent 3 41*48352Scael.Sh HISTORY 42*48352ScaelThe 43*48352Scael.Nm byteorder 44*48352Scaelfunctions appeared in 45*48352Scael.Bx 4.2 . 46*48352Scael.Sh BUGS 47*48352ScaelOn the 48*48352Scael.Tn VAX 49*48352Scaelbytes are handled backwards from most everyone else in 5020484Smckusickthe world. This is not expected to be fixed in the near future. 51