a) 10054错误描述:远程主机强迫关闭了一个现有的连接。
b) 微软提供的错误原因(英文):
If sending a datagram using the sendto function results in an “ICMP port unreachable” response and the select function is set for readfds, the program returns 1 and the subsequent call to the recvfrom function does not work with a WSAECONNRESET (10054) error response.
c) 微软提供的解决方法
添加“WINSOCK2.H”和“WS2_32.lib”文件。
添加如下代码:
#define IOC_VENDOR 0x18000000
#define _WSAIOW(x,y) (IOC_IN|(x)|(y))
#define SIO_UDP_CONNRESET _WSAIOW(IOC_VENDOR,12)
DWORD
BOOL bNewBehavior = FALSE;
DWORD status;
status = WSAIoctl(sock, SIO_UDP_CONNRESET, &bNewBehavior, sizeof(bNewBehavior), NULL, 0, &dwByteReturned, NULL, NULL);