gtpc1m3yTransmission Control Protocol/Internet Protocol

htons -- Translate a Short Integer

The htons function translates a short integer from host byte order to network byte order.

Format

#include  <types.h>
#include  <socket.h>
u_short   htons(u_short a);

a
Unsigned short integer to be put into network byte order.

Normal Return

Returns the translated short integer.

Error Return

None.

Programming Considerations

None.

Examples

The following example converts the information from host byte order to network byte order.

#include <types.h>
#include <socket.h>

·
·
·
u_short a; u_short n;
·
·
·
n = htons(a);

Related Information