Metrologic Optimus S Programming Manual page 146

"c" programming guide
Table of Contents

Advertisement

140
"C" Programming Guide For Optimus S/R
Reading & Writing Data
Nread
Nwrite
The section describes the Nread() and Nwrite() routines, which are used to send and
receive data on the network.
Purpose
To read a message from a connection.
Syntax
int Nread (int conno, char *buff, int len);
int conno;
char *buff;
int len;
Example
if (socket_hasdata (conno) > 0)
Nread (conno, buf, sizeof (buf));
Description
This routine reads a number of bytes (len) from a connection (conno) into a
specified buffer (buff).
In blocking mode, this function will block until information is available to
be read, or until a timeout occurs. The timeout can be adjusted using
socket_rxtout().
The application can avoid this blocking behavior by using socket_hasdata
to make sure there is data available before calling Nread().
The protocol stack will try to compact all of the data receiving from the
remote side. This means the data obtained from Nread() maybe comes
from different packets.
Return
If successful, it returns the number of bytes read.
Otherwise, it returns 0 to indicate the connection is closed by the remote end.
On error, it returns a negative value to indicate a specific error condition.
See Also
Nwrite, socket_hasdata, socket_rxtout
Purpose
To write a message to a connection.
Syntax
int Nwrite (int conno, char *buff, int len);
int conno;
char *buff;
int len;
/* connection number */
/* Pointer to a receive buffer */
/* max. number of bytes to receive;
normally equals to the size of buffer */
/* connection number */
/* Pointer to a send buffer */
/* maximum number of bytes to write */

Advertisement

Table of Contents
loading

This manual is also suitable for:

Optimus r

Table of Contents