@CHIP-RTOS C Library - TCP/IP API
htons
Converts a 16 bit word from host to TCP/IP network byte order. unsigned short htons ( unsigned short hostshort ); Parameters
hostshort
- 16 bit value whose byte order is to be swapped
Return Value
- input value returned with byte order swapped
Comments
- This function converts the provided 16 bit value from Intel byte
ordering (little endian) to network byte order (big endian),
or vice-versa.
This is commonly needed for TCP/IP port number specifications.
For example, calling with input value 0x1234 will return the
value 0x3412.
No entry into the @CHIP-RTOS API is made here. This action
is taken immediately within this library call.
The macro ntohs shown below is defined for use where
you want to state that the conversion is from network byte order to
host byte order. Either way, the same library code executes.
See Also
This API List
List of C Libraries
@CHIP-RTOS Main Index
End of document
|