简体   繁体   English

服务器上的 accept() 调用成功,但客户端上的 connect() 调用失败,错误代码为 10035

[英]accept() call on server is successful but connect() call on client failed with error code 10035

I've a client server model operating in non blocking mode where the server is as usual trying to accept connections infinitely.我有一个在非阻塞模式下运行的客户端服务器模型,其中服务器像往常一样尝试无限地接受连接。 And client is repeatedly trying to connect with the server until it succeeds.并且客户端反复尝试与服务器连接,直到成功。 When I run the server first and then client, I can see logs on server that the accept() call was a success but on client side the connect() call is failing with an error code 10035.当我先运行服务器然后运行客户端时,我可以看到服务器上的日志,accept() 调用成功,但在客户端,connect() 调用失败,错误代码为 10035。

Overall files are a lot bigger than than this and there's so much going on in them.总体文件比这大得多,而且其中有很多内容。 Both server & client are actually packet sniffers and the problematic part is when I try to establish a connection between these 2 sniffers to transfer information.服务器和客户端实际上都是数据包嗅探器,有问题的部分是当我尝试在这两个嗅探器之间建立连接以传输信息时。

Error code 10035 is WSAEWOULDBLOCK ( table ), which means the connection did not fail -- it just hasn't completed yet, and you need to wait a bit.错误代码 10035 是 WSAEWOULDBLOCK ( table ),这意味着连接没有失败——只是还没有完成,您需要稍等片刻。

Normally one will wait until the socket is writable or has an error condition after issuing a connect that returns this code -- once one of those two things happen, you know the connection has either completed or failed for some other reason.通常,在发出返回此代码的连接后,人们会等到套接字可写或出现错误情况——一旦发生这两种情况之一,您就知道连接已经完成或由于其他原因而失败。 You can do that wait with a select call with the descriptor included in 'writefds' and 'exceptfds' arguments.您可以使用包含在“writefds”和“exceptfds”参数中的描述符进行select调用来等待。

According to me connect() takes some time to establish a connection thus you cannot have it running in non blocking mode.根据我的说法,connect() 需要一些时间来建立连接,因此您不能让它在非阻塞模式下运行。 And server is showing no error in accept() is because of the following reason: 3 way handshake: Client sends SYN flag to the server And server responds with SYN-ACK and when server acknowledges, it returns success from accept() BUT, to complete 3 way handshake, client must send an ACK back to the server which it fails to do because of non blocking mode, thus connect() fails.服务器在 accept() 中没有显示错误是因为以下原因: 3 次握手:客户端向服务器发送 SYN 标志服务器以 SYN-ACK 响应,当服务器确认时,它从 accept() 返回成功,但是完成 3 次握手,客户端必须将 ACK 发送回服务器,但由于非阻塞模式而无法执行,因此 connect() 失败。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM