标签 Winsock 下的文章

WSAETIMEDOUT&WSAECONNREFUSED

WSAETIMEDOUT
10060

 



Connection timed out.

A connection attempt failed because the connected party did not properly respond after a period of time, or the established connection failed because the connected host has failed to respond.

WSAECONNREFUSED
10061

 



Connection refused.

No connection could be made because the target computer actively refused it. This usually results from trying to connect to a service that is inactive on the foreign host—that is, one with no server application running.

int i = connect(sck,(LPSOCKADDR)&serverInfo,sizeof(struct sockaddr));

之后,i返回-1(0xffffffff),WSAGetLastError发现错误是WSAETIMEDOUT,用网页访问发现原来服务器ip是网通的,而哥牵的是电信,ping不通也打不开网页。到了公司之后错误成了WSAECONNREFUSED。后查看代码发现这句:

serverInfo.sin_port = htons(8080);

而请求的端口应该是8088。= =#。