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

  • Home
  • SEARCH
  • 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 9223623
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 18, 20262026-06-18T04:06:59+00:00 2026-06-18T04:06:59+00:00

I am doing non-blocking TCP socket programming using select(). After normal set up, socket()

  • 0

I am doing non-blocking TCP socket programming using select().

After normal set up,

socket()
make socket non-blocking
bind()
listen()
FD_ZERO
FD_SET
  ...
select()

FD_ISSET
  ...
  s = accept()

For certain reason, after FD_ISSET the server does some preparation but then chooses not to accept. Easy way is just to close s after accept(). But before accept(), is there any way to tell the client that this connection should fail? Thank you.

  • 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-18T04:07:01+00:00Added an answer on June 18, 2026 at 4:07 am

    No. If you get an incoming connection and you don’t want it after all, you will have to accept() is and close() it right away. This is not a consequence of the way TCP (or other network protocols) work, but it is inherent in the socket API.

    Assuming we’re talking about TCP/IP, it’s instructive to note that by the time select() (or poll() or whatever) has notified you that the listening socket is ready for reading, it’s already too late to not accept the connection: the kernel has already accepted the connection on your behalf. That is, it has already sent out a SYN|ACK in response to the incoming SYN packet. That’s actually the effect of the listen() system call. After that, the call to accept() is just a formality: it allocates a new file descriptor for the accepted connection.

    The most notable piece of software that could potentially take advantage of a different way of doing things is TCP wrappers. TCP wrappers generally makes a decision as to whether or not to accept an incoming connection based solely on the remote IP address. If it were given the opportunity to make this decision and refuse the connection before it was even accepted, then it would enable clients whose connections have been denied by TCP wrappers to get a true “Connection refused” response (a RST response to the SYN packet, just the same as if nothing were listening on the port). But with the sockets interface, there is no way for it to do that. Instead the client’s connection is opened and then immediately closed.

    Not all operating systems are the same this way. For example on Cisco IOS, when you configure an access-list of on a vty port to permit incoming connections from some IP addresses and deny them from others, the denied connections get a true “Connection refused”. But it’s not implemented using sockets. (It’s probably implemented using something very proprietary.)

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

Sidebar

Related Questions

So I'm doing a pretty basic ajax request, but I can't make it non-blocking
I'm doing a sort of event loop to process multiple non-blocking sockets in Java.
I need to implement a non-blocking MessageBox that automatically closes after 20 seconds. Can
I'm running into a problem doing an MPI non-blocking send where it causes the
Using the Sun Java VM 1.5 or 1.6 on Windows, I connect a non-blocking
I'm trying to make non-blocking calls to 3 public APIs, i.e website A,B,C and
I am doing homework but I have problem with non-RestFul routes. My spec is:
Doing an ajax get request works as expected using the following code: $.ajax({ type:
Doing some jquery animation. I have certain divs set up with an attribute of
New to socket programming. Got a couple questions: My program is really inconsistent with

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.