140
"C" Programming Guide For Optimus S/R
Reading & Writing Data
The section describes the
Nread()
and
Nwrite()
routines, which are used to send and
receive data on the network.
Nread
Purpose
To read a message from a connection.
Syntax
int Nread (int conno, char *buff, int len);
int conno; /* connection number */
char *buff; /* Pointer to a receive buffer */
int len; /* max. number of bytes to receive;
normally equals to the size of buffer */
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
Nwrite
Purpose
To write a message to a connection.
Syntax
int Nwrite (int conno, char *buff, int len);
int conno; /* connection number */
char *buff; /* Pointer to a send buffer */
int len; /* maximum number of bytes to write */
Содержание Optimus R
Страница 1: ...Printed on 20 March 2006 C Programming Guide Version 3 04 02 Optimus S Optimus R...
Страница 6: ......
Страница 8: ...2 C Programming Guide For Optimus S R...
Страница 12: ...6 C Programming Guide For Optimus S R The flow is illustrated as shown below...
Страница 23: ...Chapter 2 Development Environment 17 Different types signed unsigned Different types same size...
Страница 24: ...18 C Programming Guide For Optimus S R...
Страница 220: ...214 C Programming Guide For Optimus S R See Also FlashSize free_memory...
Страница 232: ...226 C Programming Guide For Optimus S R 4 11 Implementation defined Limits limits h float h Refer to limit h and float h...
Страница 238: ...232 C Programming Guide For Optimus S R...