DOCUMENT:Q247826 24-OCT-2000 [winnt] TITLE :BUG: Using a QoS Socket with AcceptEx PRODUCT :Microsoft Windows NT PROD/VER:WINDOWS: OPER/SYS: KEYWORDS:kbnetwork kbAPI kbGQos kbOSWin2000 kbSDKPlatform kbSDKWin32 kbDSupport kbGrpDSNet ====================================================================== ------------------------------------------------------------------------------- The information in this article applies to: - Microsoft Windows 2000 Advanced Server - Microsoft Windows 2000 Server - Microsoft Windows 2000 Professional ------------------------------------------------------------------------------- SYMPTOMS ======== The AcceptEx function exhibits several problems when used with a Quality of Service (QoS) socket: - The AcceptEx function drops incoming data if it is used with a QoS socket and if AcceptEx is called with its dwReceiveDataLength parameter set to a value great than 0 (zero). If AcceptEx is called with dwReceiveDataLength set to a value of N (N greater than 0), then the application calling AcceptEx never receives the N bytes of data. Furthermore, the lost data cannot be subsequently retrieved by calling recv or WSARecv after calling AcceptEx. - The AcceptEx function may access violate if the lpOutputBuffer parameter passed in is NULL. - The lpOverlapped parameter to AcceptEx must not be NULL. - The sAcceptSocket parameter used in AcceptEx will not inherit the properties of the sListenSocket parameter after setsockopt(SO_UPDATE_ACCEPT_CONTEXT) is called, as documented for this function. RESOLUTION ========== To use the AcceptEx function with a QoS socket, please use the following guidelines: - Set the dwReceiveDataLength parameter in AcceptEx to 0, which tells AcceptEx to return as soon as a connection has been established. To obtain the data sent, call either recv or WSARecv. - Do not pass in NULL for the lpOutputBuffer parameter when calling AcceptEx (even though you do not intend to receive initial data as described in the previous item). Instead, provide a buffer size greater than or equal to (2 * (sizeof(sockaddr_in) + 16) = 64. - Call AcceptEx in an overlapped fashion and pass a pointer to a properly initialized overlapped structure in the lpOverlapped parameter in AcceptEx. - Set the dwLocalAddressLength and dwRemoteAddressLength parameters to (sizeof(sockaddr_in) + 16) = 32 when calling AcceptEx (and GetAcceptExSockaddrEx--see next item). - Call the GetAcceptExSockaddrEx function prior to calling setsockopt(SO_UPDATE_ACCEPT_CONTEXT) in order to have the sAcceptSocket parameter inherit the QoS properties of the sListenSocket parameter. If you do not call the GetAcceptExSockaddrEx function, then you will have to explicitly get the QoS settings for sListenSocket by using WSAIoctl(SIO_GET_QOS), and then set QoS on sAcceptSocket by using WSAIoctl(SIO_SET_QOS). STATUS ====== Microsoft has confirmed this to be a bug in the Microsoft products listed at the beginning of this article. REFERENCES ========== For additional information about creating a QoS socket, click the article number below to view the article in the Microsoft Knowledge Base: Q192120 HOWTO: Use the WSAPROTOCOL_INFO Structure to Create a Socket Additional query words: ====================================================================== Keywords : kbnetwork kbAPI kbGQos kbOSWin2000 kbSDKPlatform kbSDKWin32 kbDSupport kbGrpDSNet Technology : kbwin2000AdvServ kbwin2000AdvServSearch kbwin2000Serv kbwin2000ServSearch kbwin2000Search kbwin2000ProSearch kbwin2000Pro kbWinAdvServSearch Version : WINDOWS: Issue type : kbbug ============================================================================= THE INFORMATION PROVIDED IN THE MICROSOFT KNOWLEDGE BASE IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND. MICROSOFT DISCLAIMS ALL WARRANTIES, EITHER EXPRESS OR IMPLIED, INCLUDING THE WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT SHALL MICROSOFT CORPORATION OR ITS SUPPLIERS BE LIABLE FOR ANY DAMAGES WHATSOEVER INCLUDING DIRECT, INDIRECT, INCIDENTAL, CONSEQUENTIAL, LOSS OF BUSINESS PROFITS OR SPECIAL DAMAGES, EVEN IF MICROSOFT CORPORATION OR ITS SUPPLIERS HAVE BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. SOME STATES DO NOT ALLOW THE EXCLUSION OR LIMITATION OF LIABILITY FOR CONSEQUENTIAL OR INCIDENTAL DAMAGES SO THE FOREGOING LIMITATION MAY NOT APPLY. Copyright Microsoft Corporation 2000.