Hi,
I have the following function which is called by several other programs.

I am getting the socket error 10038, which means socket operation on a non socket. How do I go about troubleshooting?
How do I know which thread is calling this function?
Code:
int CSocHandler::sendAll(char * cSendBuffer, int length) {
if (length <=0) {
return 0;
}

int iTotalBytesSent = 0;
do {
int iBytesSent = ::send( sock, &cSendBuffer[iTotalBytesSent], length-iTotalBytesSent , 0);
Yield();
if (iBytesSent <= 0) {
int iErrorCode = WSAGetLastError();
cout << "\nSocket error in CSocHandler::sendAll : " << iErrorCode;
cout << " - Buffer: " << cSendBuffer << endl;
break;
}
iTotalBytesSent +=iBytesSent;
} while (iTotalBytesSent < length);

return iTotalBytesSent;
}