158
"C" Programming Guide For Optimus S/R
send
Purpose
To send data to a connected socket.
Syntax
int send (SOCKET s, char *buf, int len, int flags);
s
Descriptor identifying a connected socket
buf
Pointer to the buffer in which data is to be sent
len
Maximum number of bytes to be sent
flags
MSG_OOB: process out-of-band data
MSG_DONTROUTE: bypass routing, use direct interface
Example
SOCKET s;
char buf[1024];
int len, tlen;
...................
len = strlen (buf);
tlen = send (s, buf, len, 0);
if (tlen < 0) {
printf ("send fails on socket: %d", s);
...................
}
Description
This routine writes outgoing data to a specified send buffer (
buf
) on a
connected socket.
The
flags
argument allows one of the following values:
MSG_OOB
sends urgent data (out-of-bound data)
MSG_DONTROUTE
sends data using direct interface
The application can avoid this blocking behavior by using socket_cansend() to
make sure there is data available before calling send(). (?)
The whole data may not be sent at one time. Check the return value in case the
send buffer overflows. (?)
Return
If successful, it returns a non-negative integer (>=0) indicating the number of
bytes sent.
On error, it returns -1.
The global variable
errno
is set to indicate the error condition encountered.
See Also
recv, sendto, socket_cansend
sendto
Purpose
To send data to a connected socket.
Содержание 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...