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 973541
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 16, 20262026-05-16T03:17:42+00:00 2026-05-16T03:17:42+00:00

I have a Winsock based server application which uses Windows Winsock I/O Completion Ports.

  • 0

I have a Winsock based server application which uses Windows Winsock I/O Completion Ports.

As such, each connection accepted is associated with the listening socket to start receiving notifications (read, write, close etc’).
The listening socket has a backlog of 100 pending connections.
All is good.

At some point I want to stop accepting new connections yet keep communication with already connected existing connected sockets.

I figured I could do one of:

  1. Stop calling WSAAccept().
  2. Set the backlog to zero, effectively disallowing any connection to pend.
  3. Call shutdown() & closesocket() on the listening socket.

Now, option #1 gives the expected results; My application doesn’t process new connections, BUT it does accept up to the backlog’s amount (100). Connections are practically made – I don’t want it!

Option #2; Can I do that? How? Couldn’t find on MSDN nor google. The documentation of listen() at MSDN says;

If the listen function is called on an
already listening socket, it will
return success without changing the
value for the backlog parameter.
Setting the backlog parameter to 0 in
a subsequent call to listen on a
listening socket is not considered a
proper reset, especially if there are
connections on the socket.

Not good for me.
If I could do so in a safe way I would combine it with option #1, effectively really stopping establishing any new connections on the machine (through the listening port!).

Option #3 actually works; After closing the listening socket I can still communicate with existing connections, and the backlog is gone (well, closed the listening socket!).

My concern is that this approach might have some side-effects. Can anyone confirm?

  • 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-16T03:17:42+00:00Added an answer on May 16, 2026 at 3:17 am

    You can simply close the listening socket. The accepted connections have their own sockets and they will not be affected by closing the listening socket.

    For example, in the Microsoft documentation there is a sample server application where basic socket usage is demonstrated. There the listening socket is closed before communication over the accepted socket is done (before the do-while-loop).

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

Sidebar

Related Questions

I have win32 application in which winsock is used for TCP/IP communication. I am
I have a very large C++ server application on Windows (Win7). It compiles fine
I`m writing client-server app for windows using WinSock and I have class for server.
I have a driver which can be installed on Windows (XP/Vista/7). It's accessed via
System Description: I have a WCF service (self hosted in a windows service) which
I am implementing a Windows-based web server handling multiple specific HTTP requests from clients
I have a program in C++ using winsock that connects to a server, the
I've been programming a simple WinSock application in Visual Studio 2010. I have named
I have an Application (written in C/C++) thats communicating over UDP between many Windows
I have a C++ application which accepts TCP connections and then reads the traffic

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.