[oclug] ntohs and friends
David F. Skoll
dfs at roaringpenguin.com
Wed Apr 4 07:13:25 EDT 2001
On Wed, 4 Apr 2001, Brenda J. Butler wrote:
> I've seen the functions hton and ntoh (host-to-network order and
> network-to-host order) used to diddle the byte orders. Not
> sure if they are "portable" (ie "supplied with the system on
> virtually all platforms").
noths, htons, ntohl and htonl are standard POSIX functions.
> I think there must have been versions
> of hton and ntoh for each of float, long, int, etc. Perhaps ntohf,
> ntohl, etc???
No; there are no standard representations for floating-point numbers.
If you really need to transmit floats, you could use Sun's XDR
(eXternal Data Representation) which is used for RPC calls, and has
flexible and complicated ways to encode just about anything in a
network-standard way.
--
David.
More information about the OCLUG
mailing list