CAsyncSocket m_ClientSock;
m_ClientSock.Create();
res = m_ClientSock.Connect("127.0.0.1", 1001);
if (res == 0)
{
str.Format("%d", GetLastError());
AfxMessageBox("连接失败"+ str);
return;
}连接失败的错误代码是10035,我不知道哪里出错了?
m_ClientSock.Create();
res = m_ClientSock.Connect("127.0.0.1", 1001);
if (res == 0)
{
str.Format("%d", GetLastError());
AfxMessageBox("连接失败"+ str);
return;
}连接失败的错误代码是10035,我不知道哪里出错了?
CSocket m_ClientSock;
m_ClientSock.Create();
int res = m_ClientSock.Connect("127.0.0.1", 1001);
while(res == 10035)
{
res = m_ClientSock.Connect("127.0.0.1", 1001);
}
你这个是正常的。10035表示无法立即完成一个非阻止性套接字操作。
用同步套接字类CSocket不会出现这个问题。
m_ClientSock.Create();
int res = m_ClientSock.Connect("127.0.0.1", 1001);
while(res == 0 && GetLastError() == 10035)
{
res = m_ClientSock.Connect("127.0.0.1", 1001);
}
m_ClientSock.Create();
int res = m_ClientSock.Connect("127.0.0.1", 1001);
while(res == 0 && GetLastError() == 10035)
{
sleep(1000); //这样会不会好些?
res = m_ClientSock.Connect("127.0.0.1", 1001);
}
mk:@MSITStore:F:\MSDN\MSDN2000\MSDN\WinSock.chm::/devdoc/good/pdnds/sock2/errors_0oaa.htm
WSAEWOULDBLOCK
(10035)
Resource temporarily unavailable.
This error is returned from operations on non-blocking sockets that cannot be completed immediately, for example recv when no data is queued to be read from the socket. It is a non-fatal error, and the operation should be retried later. It is normal for WSAEWOULDBLOCK to be reported as the result from calling connect on a non-blocking SOCK_STREAM socket, since some time must elapse for the connection to be established. mk:@MSITStore:F:\MSDN\MSDN2000\MSDN\mswnsk98.chm::/html/vbevterrorevent.htmsckInvalidArgument 10014 所请求的地址是广播地址,但未设置标记。
sckWouldBlock 10035 套接字不成块,而指定操作将使之成块。
sckInProgress 10036 制造块的 Winsock 操作在进行之中。