Metrologic Optimus S Programming Manual page 169

"c" programming guide
Table of Contents

Advertisement

Byte Swapping
htonl
Purpose
To convert an unsigned long integer from host byte order to network byte
order.
unsigned long htonl (unsigned long val);
Syntax
unsigned long val;
Example
(?)
This routine converts an unsigned long integer from host byte order to network
Description
byte order.
Return
If successful, it returns the value of conversion.
Otherwise (?)
See Also
ntohl
htons
Purpose
To convert an unsigned (short) integer from host byte order to network byte
order.
Syntax
unsigned htons (unsigned val);
unsigned val;
Example
struct sockaddr_in name;
s = socket (PF_INET, SOCK_STREAM, TCP);
if (s < 0) {
}
memset (&name, 0, sizeof (name));
name.sin_family = AF_INET;
name.sin_port = htons (3000);
Description
This routine converts an unsigned (short) integer from host byte order to
network byte order.
Return
If successful, it returns the value of conversion.
Otherwise (?)
See Also
ntohs
Chapter 3 Terminal Specific Function Library
printf ("SOCKET allocation failed");
.......................
/* an unsigned long integer to be converted */
/* an unsigned integer to be converted */
163

Advertisement

Table of Contents
loading

This manual is also suitable for:

Optimus r

Table of Contents