'\" te .\" Copyright (c) 2008, 2012, Oracle and/or its affiliates. All rights reserved. .\" Copyright 1989 AT&T .TH byteorder 3SOCKET "11 Jul 2012" "SunOS 5.11" "Sockets Library Functions" .SH NAME byteorder, htonl, htonll, htons, ntohl, ntohll, ntohs \- convert values between host and network byte order .SH SYNOPSIS .LP .nf \fBcc\fR [ \fIflag\fR... ] \fIfile\fR... \fB-lsocket\fR \fB -lnsl \fR [ \fIlibrary\fR... ] #include #include #include \fBuint32_t\fR \fBhtonl\fR(\fBuint32_t\fR \fIhostlong\fR); .fi .LP .nf \fBuint64_t\fR \fBhtonll\fR(\fBuint64_t\fR \fIhostlonglong\fR); .fi .LP .nf \fBuint16_t\fR \fBhtons\fR(\fBuint16_t\fR \fIhostshort\fR); .fi .LP .nf \fBuint32_t\fR \fBntohl\fR(\fBuint32_t\fR \fInetlong\fR); .fi .LP .nf \fBuint64_t\fR \fBntohll\fR(\fBuint64_t\fR \fIhostlonglong\fR); .fi .LP .nf \fBuint16_t\fR \fBntohs\fR(\fBuint16_t\fR \fInetshort\fR); .fi .SH DESCRIPTION .sp .LP These functions convert 16-bit, 32-bit, and 64-bit quantities between network byte order and host byte order. On some architectures these routines are defined as \fINULL\fR macros in the include file <\fBnetinet/in.h\fR>. On other architectures, the routines are functional when the host byte order is different from network byte order. .sp .LP These functions are most often used in conjunction with Internet addresses and ports as returned by \fBgethostent()\fR and \fBgetservent()\fR. See \fBgethostbyname\fR(3NSL) and \fBgetservbyname\fR(3SOCKET). .SH ATTRIBUTES .sp .LP See \fBattributes\fR(5) for descriptions of the following attributes: .sp .sp .TS tab() box; cw(2.75i) |cw(2.75i) lw(2.75i) |lw(2.75i) . ATTRIBUTE TYPEATTRIBUTE VALUE _ MT-LevelSafe .TE .SH SEE ALSO .sp .LP \fBgethostbyname\fR(3NSL), \fBgetservbyname\fR(3SOCKET), \fBinet.h\fR(3HEAD), \fBattributes\fR(5)