Error 10054 in iocp

Source: Internet
Author: User
Tags knowledge base

Recently, in UDP communication tests on the iocp model, we found that if the UDP socket on the server directly sends data to a client and the client does not exist
The above getqueuedcompletionstatus will be activated, but an error is returned. The data size is 0,
In addition, if the wsarecvfrom request is sent again, the getqueuedcompletionstatus will be immediately received even if no client sends data.
The returned error message will no longer be able to receive client data. After analysis, you can use the following methods to solve this problem.

 

To solve this problem, obtain the latest service pack for Windows 2000. For more information, click the following article number to view the article in the Microsoft Knowledge Base:

260910 (http://support.microsoft.com/kb/260910/) How to get the latest Windows 2000 Service Pack

In Windows 2000, a new socket named IOCTL "sio_udp_connreset" was introduced ". Specifically, to obtain the behavior of the original Windows NT 4.0 Windows 2000 when using this ioctl, you must override this program. Windows NT 4.0, Microsoft Windows 95, and Microsoft Windows 98 do not support this new IOCTL. In addition to rewriting the application, you will need to reference the patch further in this article.

The following code snippet demonstrates a technology that can be used to obtain the original Windows NT 4.0 behavior. In the code of the io_udp_connreset control, wsaioctl is called.

DWORDdwBytesReturned = 0;BOOLbNewBehavior = FALSE;DWORDstatus;// disable  new behavior using// IOCTL: SIO_UDP_CONNRESETstatus = 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 doreturn(FALSE);}else{printf("WSAIoctl(SIO_UDP_CONNRESET) Error: %d/n", dwErr);return(FALSE);}}

To compile this code, you need to have the latest mswsock. H, including the definition of sio_udp_connreset, or define its direct insert to the code below

// MS Transport Provider IOCTL to control// reporting PORT_UNREACHABLE messages// on UDP sockets via recv/WSARecv/etc.// Path TRUE in input buffer to enable (default if supported),// FALSE to disable.#defineSIO_UDP_CONNRESET_WSAIOW(IOC_VENDOR,12)

Note:The patch described in this article does not resolve this issue unless the program uses the new sio_udp_connreset IOCTL to be overwritten.

For details, see http://support.microsoft.com/kb/263823. you only need to call the following method in UDP socket creation to solve status = wsaioctl (SD, sio_udp_connreset,
& Bnewbehavior, sizeof (bnewbehavior ),
Null, 0, & dwbytesreturned,
Null, null );

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.