18,356
社区成员
发帖
与我相关
我的任务
分享
errorInfo CIOCPModel::Send(PER_IO_CONTEXT* pIoContext, SOCKET socket, char* strBuff, int offset, int length){
errorInfo back;
int result = -1;
int temp = strlen((char*)strBuff);
int err = 0;
WSABUF DataBuf;
DWORD SendBytes, Flags;
char buffer[1024];
DataBuf.len = length;
DataBuf.buf = strBuff;
pIoContext->m_Overlapped.hEvent = WSACreateEvent();
result = WSASend(socket, &DataBuf,1, &SendBytes, 0, &pIoContext->m_Overlapped, NULL);
DWORD a = GetLastError();
//result = send(socket, (const char*)(char*)strBuff, strlen((char*)strBuff) + 1, 0);
if (result < 0){
if (WSAGetLastError() != ERROR_IO_PENDING)
{
DWORD a = WSAGetLastError();
str.Format("WSASend failed!,errorcode=%d\n", WSAGetLastError());
logFile.write(str, str.GetLength());
//printf("WSASend() failed with error %d\n", WSAGetLastError());
}
back.errorCode = WSAGetLastError();
back.errorStr = "send error";
}
else{
back.errorCode = 0;
}
_PostSend(pIoContext);
return back;
我也遇到同样的问题,不知哪里出了问题?