[Previous] [Contents] [Index] [Next]

htons()

Convert a 16-bit value from host-byte order to network-byte order

Synopsis:

#include <netinet/in.h>

in_port_t htons( in_port_t hostshort );

Library:

socket3r.lib, socket3s.lib

Description:

The htons() function converts a 16-bit value from host-byte order to network-byte order.

This routine is most often used in conjunction with internet addresses and ports returned by gethostbyname() and getservent().

Returns:

The value in network-byte order.

Classification:

Standard Unix, POSIX 1003.1g (draft)

Safety:
Interrupt handler Yes
Signal handler Yes
Thread Yes

See also:

gethostbyname(), getservent(), htonl(), ntohl(), ntohs()


[Previous] [Contents] [Index] [Next]