RCSocketResult RCAsyncSocket::Send(const char* pBuff, int32_t nLen, int32_t& nLenSent, DWORD dwTimeOut)
{
m_nLastError = 0;
int32_t bytesSent = 0;
int32_t sendLeft = nLen;
nLenSent = 0;
HANDLE arrHandles[3];
int32_t waitCount = (m_breakEvent != NULL) ? 3 : 2;
arrHandles[0] = m_eventNet.GetEvent();
arrHandles[1] = m_eventStop.GetEvent();
arrHandles[2] = m_breakEvent;
do
{
bytesSent = send(m_hSocket, pBuff, sendLeft, 0);;
if (bytesSent == SOCKET_ERROR)
{
m_nLastError = WSAGetLastError();
if (m_nLastError != WSAEWOULDBLOCK)
{
//WRITE_DEBUG_LOG(RCMOBILE_MODDULE_CONNECT_GUID, _T(" RCAsyncSocket::Send Error 01 with error code %d"), m_nLastError);
return RC_SOCKET_SOCKERR;
}
bytesSent = 0;
DWORD dwWaitRes = WaitForMultipleObjects(waitCount, arrHandles, FALSE, dwTimeOut);
if (dwWaitRes == WAIT_OBJECT_0 + 1 || dwWaitRes == WAIT_OBJECT_0 + 2)
{
m_nLastError = WSAGetLastError();
//WRITE_DEBUG_LOG(RCMOBILE_MODDULE_CONNECT_GUID, _T(" RCAsyncSocket::Se
send和recv非阻塞时如何正确处理WSAEWOULDBLOCK和设置超时
最新推荐文章于 2020-09-09 10:28:42 发布
![](https://img-home.csdnimg.cn/images/20240611030827.png)