Linux and UNIX Man Pages

Linux & Unix Commands - Search Man Pages

htons(3) [osf1 man page]

htons(3)						     Library Functions Manual							  htons(3)

NAME
htons - Converts an unsigned short (16-bit) integer from host byte order to network byte order LIBRARY
Standard C Library (libc.so, libc.a) SYNOPSIS
#include <arpa/inet.h> in_port_t htons ( in_port_t hostshort) ; STANDARDS
Interfaces documented on this reference page conform to industry standards as follows: htons(): XNS4.0 Refer to the standards(5) reference page for more information about industry standards and associated tags. PARAMETERS
Specifies a 16-bit integer in host byte order. DESCRIPTION
The htons() (host-to-network short) function converts an unsigned short (16-bit) integer from host byte order to Internet network-byte order. The Internet network requires address and port reference data in network-byte order. Use the htons() function to convert address and port short integers from host byte order to Internet network-byte order. RETURN VALUES
Upon successful completion, the htons() function returns a 16-bit short integer in Internet network-byte order. ERRORS
Current industry standards do not define error values for the htons() function. RELATED INFORMATION
Functions: endhostent(3), endservent(3), htonl(3), ntohl(3), ntohs(3). Standards: standards(5). Network Programmer's Guide delim off htons(3)

Check Out this Related Man Page

BYTEORDER(3)						     Linux Programmer's Manual						      BYTEORDER(3)

NAME
htonl, htons, ntohl, ntohs - convert values between host and network byte order SYNOPSIS
#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
The htonl() function converts the unsigned integer hostlong from host byte order to network byte order. The htons() function converts the unsigned short integer hostshort from host byte order to network byte order. The ntohl() function converts the unsigned integer netlong from network byte order to host byte order. The ntohs() function converts the unsigned short integer netshort from network byte order to host byte order. On the i386 the host byte order is Least Significant Byte first, whereas the network byte order, as used on the Internet, is Most Signifi- cant Byte first. CONFORMING TO
POSIX.1-2001. Some systems require the inclusion of <netinet/in.h> instead of <arpa/inet.h>. SEE ALSO
endian(3), gethostbyname(3), getservent(3) COLOPHON
This page is part of release 3.27 of the Linux man-pages project. A description of the project, and information about reporting bugs, can be found at http://www.kernel.org/doc/man-pages/. GNU
2009-01-15 BYTEORDER(3)
Man Page

8 More Discussions You Might Find Interesting

1. UNIX for Dummies Questions & Answers

Network Configuration Commands.....

I need to know what commands I will need to use to change a host name, IP Address, and network configurations (routerings, dns, etc) and a Unix SCO machine. Also, if there is any short tutorials on using the commands, i would defiently like that information. Thanks!!! (1 Reply)
Discussion started by: HandleX
1 Replies

2. IP Networking

What does 'AF' of AF_INET stand for ?

as title. and how is it different from PF_INET ? also, any one knows sin_family , sin_port , sin_addr ..etc ? why are they called 'sin' ? finally, htons() host to network short , htonl() host to network long , ntohs() network to host short , ntohl() network to host long. why would... (6 Replies)
Discussion started by: trapeze
6 Replies

3. UNIX for Dummies Questions & Answers

htons and ntohs

Hi All, I am running a short program on the effects of host-to-network and network-to-host functions. The following is part of my code: int a = 384; printf("Used htons with a, getting: %x Hex and %d Numeral\n", htons(a), htons(a)); printf("Used ntohs with a, getting: %x Hex and %d... (1 Reply)
Discussion started by: dbshuis
1 Replies

4. UNIX for Dummies Questions & Answers

How to determine if a host is connected to the Internet in Unix?

How to determine if a host is connected to the Internet in Unix ? (1 Reply)
Discussion started by: shuhang2
1 Replies

5. Programming

How to use htons() function?

Hi I am constructing an ICMP packet using C++ and want to convert sequence number into network byte order. I know we can use htons: here is my code: struct ICMPheader { unsigned int seqence_no; }; ICMPheader header; header.sequence_no = htons (sequence_no++); but it is giving... (3 Replies)
Discussion started by: manmeet
3 Replies

6. IP Networking

testing network elements

for testing network elements which of the below is TRUE a)Thorough understanding of RFC s/ IETF standards is enough. b)One has to know design specifications along with standards and specification. c)Understanding customer requirements is required for acceptance test only and not for... (0 Replies)
Discussion started by: venkatadilip
0 Replies

7. What is on Your Mind?

Career Path

First I like to say hi to all the people in this community. The reason I am here is because I am lost and looking for advice on my career path. Here is a short history. I worked in the IT industry for about 10 yrs, sys admin, QA, and developer. During 911 I lost my job. Since then I have... (4 Replies)
Discussion started by: navy
4 Replies

8. News, Links, Events and Announcements

Airlines industry

Hi, I want to move to unix admin from support. Which unix can i learn to get into airlines industry projects? Thanks in advance. (1 Reply)
Discussion started by: sam_bd
1 Replies