有关winsock使用的问题 [英] Question about the usage of winsock
问题描述
好吧,我已经使用Winsock了一段时间了,我遇到了一些我完全不愿意忽略的东西.我的服务器通过使用非阻塞功能的命令提示符运行.我有一个基于win32的客户端,并且使用了异步套接字.现在,我的问题来自这样一个事实,即服务器是否正在运行,或者我是否输入了一些不存在的虚假ip,connect函数始终返回错误代码10035(WSAEWOULDBLOCK).我不认为它应该这样做.即使这样,当我在服务器上启动服务器,并且在客户端中将ip放入localhost时,服务器也会报告已接收到连接.但是,在客户端上的连接仍然返回相同的错误.
okay, i''ve been using winsock for a little while now, and i''ve run into something i''m not entirely comfortable with ignoring. I have a server run through command prompt that uses non-blocking functions. I have a client that is win32 based and uses Async Sockets. Now, my question arises from the the fact that, whether or not the server is running, or whether i put in some bogus ip that doesn''t exist, the connect function always return error code 10035 (WSAEWOULDBLOCK). I don''t think it should do this. Even so, when i have the server up on my comp, and i put in localhost for the ip in the client, the server does report that it has received a connection. however, connect on the client still returns the same error. what is going on here?
推荐答案
此错误是由无法立即完成的非阻塞套接字上的操作返回的,例如,当没有数据排队等待从套接字读取时,recv.
这是一个非致命错误,应稍后重试该操作.在非阻塞的SOCK_STREAM套接字上调用connect的结果是报告WSAEWOULDBLOCK,这是正常的,因为必须花费一些时间才能建立连接.
Hi,
This error is returned from operations on nonblocking 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 nonblocking SOCK_STREAM socket, since some time must elapse for the connection to be established.
这篇关于有关winsock使用的问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!