xref: /titanic_51/usr/src/man/man3xnet/htonl.3xnet (revision 45818ee124adeaaf947698996b4f4c722afc6d1f)
te
Copyright (c) 1992, X/Open Company Limited All Rights Reserved Portions Copyright (c) 1998, Sun Microsystems, Inc. All Rights Reserved
Sun Microsystems, Inc. gratefully acknowledges The Open Group for permission to reproduce portions of its copyrighted documentation. Original documentation from The Open Group can be obtained online at
http://www.opengroup.org/bookstore/.
The Institute of Electrical and Electronics Engineers and The Open Group, have given us permission to reprint portions of their documentation. In the following statement, the phrase "this text" refers to portions of the system documentation. Portions of this text are reprinted and reproduced in electronic form in the Sun OS Reference Manual, from IEEE Std 1003.1, 2004 Edition, Standard for Information Technology -- Portable Operating System Interface (POSIX), The Open Group Base Specifications Issue 6, Copyright (C) 2001-2004 by the Institute of Electrical and Electronics Engineers, Inc and The Open Group. In the event of any discrepancy between these versions and the original IEEE and The Open Group Standard, the original IEEE and The Open Group Standard is the referee document. The original Standard can be obtained online at http://www.opengroup.org/unix/online.html.
This notice shall appear on any product containing this material.
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]
HTONL 3XNET "Jun 10, 2002"
NAME
htonl, htons, ntohl, ntohs - convert values between host and network byte order
SYNOPSIS

cc [ flag ... ] file ... -lxnet [ library ... ]
#include <arpa/inet.h>

uint32_t htonl(uint32_t hostlong);

uint16_t htons(uint16_t hostshort);

uint32_t ntohl(uint32_t netlong);

uint16_t ntohs(uint16_t  netshort);
DESCRIPTION

These functions convert 16-bit and 32-bit quantities between network byte order and host byte order.

The uint32_t and uint16_t types are made available by inclusion of <inttypes.h>.

USAGE

These functions are most often used in conjunction with Internet addresses and ports as returned by gethostent(3XNET) and getservent(3XNET).

On some architectures these functions are defined as macros that expand to the value of their argument.

RETURN VALUES

The htonl() and htons() functions return the argument value converted from host to network byte order.

The ntohl() and ntohs() functions return the argument value converted from network to host byte order.

ERRORS

No errors are defined.

ATTRIBUTES

See attributes(5) for descriptions of the following attributes:

ATTRIBUTE TYPE ATTRIBUTE VALUE
Interface Stability Standard
MT-Level MT-Safe
SEE ALSO

endhostent(3XNET), endservent(3XNET), attributes(5), standards(5)