我使用的是http://social.msdn.microsoft.com/Forums/en/vcgeneral/thread/126639f1-487d-4755-af1b-cfb8bb64bdf8上發佈的代碼,但它不像第一篇文章中所述的那樣發送數據。我如何使用WSAGetLastError(),就像它在解決方案中說的那樣,以查明哪裏出了問題?Winsock IRC客戶端連接但不發送數據
我試過如下:
void IRC::SendBuf(char* sendbuf)
{
int senderror = send(m_socket, sendbuf, sizeof(sendbuf), MSG_OOB);
if(senderror == ERROR_SUCCESS) {
printf("Client: The test string sent: \"%s\"\n", sendbuf);
}
else {
cout << "error is: " << senderror << ", WSAGetLastError: " << WSAGetLastError() << endl;
printf("Client: The test string sent: \"%s\"\n", sendbuf);
}
}
,輸出是:錯誤是:4,WSAGetLastError:0
現在它打印0.不應該得到這裏列出的代碼之一? http://msdn.microsoft.com/en-us/library/ms740668%28VS.85%29.aspx#winsock.wsaeshutdown_2 – thorvald 2010-11-28 07:34:32