Sunday 15 May 2011

Sockets Conversion Functions

There are two types of byte ordering: most significant byte and least significant byte.
This former is called "Network Byte Order" and some machines store their numbers internally
in Network Byte Order.

There are two types you can convert: short and long.
Imagine you want to convert a long from Host Byte Order to Network Byte Order.

 The following functions are used to convert :

 htons() -> "Host to Network Short"
 htonl() -> "Host to Network Long"
 ntohs() -> "Network to Host Short"
 ntohl() -> "Network to Host Long"

No comments:

Post a Comment