使用winsock 的 recv from 函数时,可能收到 ICMP port unreachable 的错误,可以通过 WSAIoctl来设置,
win2000 要使用最新的 sp来获得支持
DWORDdwBytesReturned = 0;
BOOLbNewBehavior = FALSE;
DWORDstatus;
// disable new behavior using
// IOCTL: SIO_UDP_CONNRESET
status = WSAIoctl(sd, SIO_UDP_CONNRESET,
&bNewBehavior, sizeof(bNewBehavior),
NULL, 0, &dwBytesReturned,
NULL, NULL);
if (SOCKET_ERROR == status)
{
DWORD dwErr = WSAGetLastError();
if (WSAEWOULDBLOCK == dwErr)
{
// nothing to do
return(FALSE);
}
else
{
printf("WSAIoctl(SIO_UDP_CONNRESET) Error: %d/n", dwErr);
return(FALSE);
}
}