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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 1, 20262026-06-01T05:02:02+00:00 2026-06-01T05:02:02+00:00

I need to create a server socket, which should reject a connect request, if

  • 0

I need to create a server socket, which should reject a connect request, if it is not blocking at the accept call.

The behavior of the server will be

a. wait for a client to connect
b. wait till the client closes the connection
c. Goto step a

if the server is waiting for the client connection to close, it should reject a client connect call immediately. We cannot close the server socket after getting a client connection.

Is that possible?

  • 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-06-01T05:02:04+00:00Added an answer on June 1, 2026 at 5:02 am

    What you ask for simply not possible on the server side. There is simply no way to reject a pending connection while it is still in the queue waiting to be accepted. You can (and should) set the backlog value to 1 when calling listen(), but that just means there can be at most 1 connection in the queue while you are actively communicating with another client. You would have to call accept() to remove that pending connection from the queue and then call closesocket() on it immediately if you don’t want to talk to that client at that time.

    What you can do instead is call WSAAccept() instead of accept() so you can assign a callback function that returns CF_REJECT or CF_ACCEPT as needed, and then you need to continuously call WSAAccept(), either in a thread or with overlapped I/O, to remove pending connections from the queue and reject them while you are communicating with an accepted connection until you close it.

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

Sidebar

Related Questions

Need to create a custom DNS name server using C which will check against
I need to create a pool of socket connections which will be served to
I need to create a socket which connects to a server process, but must
I need to create a server which creates a new thread for each client
I've a server in Java which listens the request on the UDP socket port
I need to create a server process which can push high frequency data (1000
Need to create a client server application, both have to communicate with Database. Which
I need call and pass parameter to NodeJS socket server. I confirmed the server
I need to create 1000 server sockets using Java. Somewhere between creating 600 and
I need to create an entirely new Sql Server 2008 database and want to

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.