Example Code: SendBytes
//--------------------------------------------------------------------
// Define SendBytes()
BOOL SendBytes (SOCKET s, PBYTE pBuf, DWORD cbBuf)
{
PBYTE pTemp = pBuf;
int eNumber;
int cbSent;
int cbRemaining = cbBuf;
if (cbBuf< 1)
{
return(TRUE);
}
while (cbRemaining)
{
cbSent = send(
s,
(const char *)pTemp,
cbRemaining,
0);
if (SOCKET_ERROR == cbSent)
{
eNumber = WSAGetLastError();
if(eNumber == WSAENETRESET)
printf("1 net reset.\n");
else
if(eNumber == WSAENOBUFS)
printf("2 no buffs.\n");
else
if(eNumber == WSAENOTCONN)
printf("3not conn .\n");
printf("socket error %d.\n ",eNumber);
HandleError("send failed.");
}
pTemp += cbSent;
cbRemaining -= cbSent;
} // end while.
return TRUE;
} // End SendBytes