'\" te .\" Copyright (c) 2008, Sun Microsystems, Inc. All Rights Reserved .\" Copyright 1989 AT&T .\" The contents of this file are subject to the terms of the Common Development and Distribution License (the "License"). You may not use this file except in compliance with the License. .\" You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE or http://www.opensolaris.org/os/licensing. See the License for the specific language governing permissions and limitations under the License. .\" When distributing Covered Code, include this CDDL HEADER in each file and include the License file at usr/src/OPENSOLARIS.LICENSE. If applicable, add the following below this CDDL HEADER, with the fields enclosed by brackets "[]" replaced with your own identifying information: Portions Copyright [yyyy] [name of copyright owner] .TH BYTEORDER 3SOCKET "Nov 23, 2015" .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 .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 .LP See \fBattributes\fR(5) for descriptions of the following attributes: .sp .sp .TS box; c | c l | l . ATTRIBUTE TYPE ATTRIBUTE VALUE _ MT-Level Safe .TE .SH SEE ALSO .LP \fBgethostbyname\fR(3NSL), \fBgetservbyname\fR(3SOCKET), \fBinet.h\fR(3HEAD), \fBattributes\fR(5)