Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 4243628
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 21, 20262026-05-21T03:36:11+00:00 2026-05-21T03:36:11+00:00

Like the title says, is it possible for a successful WSASend call on a

  • 0

Like the title says, is it possible for a successful WSASend call on a socket associated with an I/O completion port to not post a completion for any reason other than the thread ending?

I have a strange situation where it looks like a completion isn’t being posted for a WSASend, which results in a socket leak; the application thinks a send is still pending for the socket and refuses to release it.

The send code is as follows:

void CSocketServer::Write(
    Socket *pSocket,
    CIOBuffer *pBuffer) const
{
    pSocket->AddRef();

    pBuffer->SetOperation(IO_Write_Completed);
    pBuffer->SetupWrite();
    pBuffer->AddRef();

    DWORD dwFlags = 0;
    DWORD dwSendNumBytes = 0;

    if (SOCKET_ERROR == ::WSASend(
        pSocket->m_socket,
        pBuffer->GetWSABUF(), 
        1, 
        &dwSendNumBytes,
        dwFlags,
        pBuffer, 
        NULL))
    {
        DWORD lastError = ::WSAGetLastError();

        if (ERROR_IO_PENDING != lastError)
        {
            pSocket->OnConnectionError(WriteError, pBuffer, lastError);

            pSocket->WriteCompleted();  // this pending write will never complete...

            pSocket->Release();
            pBuffer->Release();
        }
    }
    // Note: even if WSASend returns SUCCESS an IO Completion Packet is 
    // queued to the IOCP the same as if ERROR_IO_PENDING was returned.
    // Thus we need no special handling for the non error return case.
    // See http://support.microsoft.com/default.aspx?scid=kb;en-us;Q192800
    // for details.
}
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-21T03:36:11+00:00Added an answer on May 21, 2026 at 3:36 am

    Are you using any of the funky new features, like turning off completions for successful calls using FILE_SKIP_COMPLETION_PORT_ON_SUCCESS?

    Are you doing any form of flow control on your sends or are you just sending whenever you feel like it and as often as you want? What you MIGHT be seeing is simply a SLOW completion due to the fact that the TCP stack is doing congestion control and cant send your data yet. If you keep sending data in an uncontrolled manner you can often get into a situation where completions start taking longer and longer to occur. Especially if you are sending data at a faster rate than the TCP connection is successfully getting it to the other side and especially if the TCP window isn’t that big. See here: http://www.lenholgate.com/blog/2008/07/write-completion-flow-control.html for some more information.

    Of course it could simply be a bug in your send logic, could you post some code?

    Note that there’s a known bug with WSARecv() and UDP (so nothing to do with your question at all) when using FILE_SKIP_COMPLETION_PORT_ON_SUCCESS which gives the situation that you describe if the datagram is bigger than the buffer that you supply and the WSARecv() call would have generated an WSAEMOREDATA; see here: http://www.lenholgate.com/blog/2010/01/file-skip-completion-port-on-success-and-datagram-socket-read-errors.html

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Like the title says, is it possible? My purpose is to make a little
Like the title says: Is it possible to export my javadoc comments for web
Well like the title says, how can I connect Outlook with asp.net or any
Like the title says I'm having some trouble printing out symbol codes and their
Like the title says, I'm wondering if the use of WebClient is the proper
Like the title says, PHP is really confusing me on a simple if comparison
Like the title says, I'm trying to determine if data is a standard attribute
Like the title says, I need a way to detect if the build is
so basically like the title says is there a way to use NSSortDescriptor to
So, just like the title says, I need to create an application that gets

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.