This method sends data through
the socket.
Signatureint RiCOSSocket_send (RiCOSSocket *const me,
const char *buf, int bufLen);
Parametersme
The RiCOSSocket object
buf
The constant string buffer that contains
the data to be sent
bufLen
The length of the buffer
ReturnsThe method returns one of the following values:
- 0 - There was an error.
- n - The number of bytes sent.
Example
int RiCOSSocket_send(RiCOSSocket * const me,
const char * buf, int bufLen)
{
int bytes_writ = 0;
int n;
if (me==NULL) return -1;
while (bytes_writ < bufLen) {
n = send(me->theSock, (char *)(buf + bytes_writ),
bufLen - bytes_writ, 0);
if (SOCKET_ERROR == n) {
if (errno == EINTR) {
continue;
}
else {
return -1;
}
}
bytes_writ += n;
}
return bytes_writ;
}