1*61150Sbostic.\" Copyright (c) 1983, 1991, 1993 2*61150Sbostic.\" The Regents of the University of California. All rights reserved. 320484Smckusick.\" 443572Strent.\" %sccs.include.redist.man% 520484Smckusick.\" 6*61150Sbostic.\" @(#)byteorder.3 8.1 (Berkeley) 06/04/93 736751Sbostic.\" 848352Scael.Dd 948352Scael.Dt BYTEORDER 3 1048352Scael.Os BSD 4.2 1148352Scael.Sh NAME 1248352Scael.Nm htonl , 1348352Scael.Nm htons , 1448352Scael.Nm ntohl , 1548352Scael.Nm ntohs 1648352Scael.Nd convert values between host and network byte order 1748352Scael.Sh SYNOPSIS 1848352Scael.Fd #include <sys/param.h> 1948352Scael.Ft u_long 2048352Scael.Fn htonl "u_long hostlong" 2148352Scael.Ft u_short 2248352Scael.Fn htons "u_short hostshort" 2348352Scael.Ft u_long 2448352Scael.Fn ntohl "u_long netlong" 2548352Scael.Ft u_short 2648352Scael.Fn ntohs "u_short netshort" 2748352Scael.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. 3248352Scael.Pp 3320484SmckusickThese routines are most often used in conjunction with Internet 3420484Smckusickaddresses and ports as returned by 3548352Scael.Xr gethostbyname 3 3620484Smckusickand 3748352Scael.Xr getservent 3 . 3848352Scael.Sh SEE ALSO 3948352Scael.Xr gethostbyname 3 , 4048352Scael.Xr getservent 3 4148352Scael.Sh HISTORY 4248352ScaelThe 4348352Scael.Nm byteorder 4448352Scaelfunctions appeared in 4548352Scael.Bx 4.2 . 4648352Scael.Sh BUGS 4748352ScaelOn the 4848352Scael.Tn VAX 4948352Scaelbytes are handled backwards from most everyone else in 5020484Smckusickthe world. This is not expected to be fixed in the near future. 51