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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 22, 20262026-05-22T16:30:57+00:00 2026-05-22T16:30:57+00:00

I have a conceptual question regarding socket programming and running the select command in

  • 0

I have a conceptual question regarding socket programming and running the select command in a while loop. Check out this excerpt from a sample echo server (written in python, but the language doesn’t matter): http://ilab.cs.byu.edu/python/select/echoserver.html

while running: 
  inputready,outputready,exceptready = select.select(input,[],[]) 

  for s in inputready: 

    if s == server: 
        # handle the server socket 
        client, address = server.accept() 
        input.append(client) 

    elif s == sys.stdin: 
        # handle standard input 
        junk = sys.stdin.readline() 
        running = 0 

    else: 
        # handle all other sockets 
        data = s.recv(size) 
        if data: 
            s.send(data) 
        else: 
            s.close() 
            input.remove(s) 

Question: what is the expected behavior while the process is executing code in the for loop if a new client connects and sends data at that moment? Is there a buffer of some kind that is part of the default sockets library such that on the subsequent select call it would immediately return with the value that had come in while it was processing the earlier request? Or would a new client connecting while the server is not actually waiting in the select() be ignored, and as such it is always possible (albeit unlikely, given we are talking milliseconds) for requests to be dropped?

(NOTE: I did some empirical testing on a different codebase that uses sockets and it appears that there is a buffer — if that is in fact by design, what is the typical size of this buffer?)

  • 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-22T16:30:57+00:00Added an answer on May 22, 2026 at 4:30 pm

    The kernel network stack handles new connections asynchronously to your process, and it will never drop an incoming connection unless it would exceed the listen backlog.

    So unless you are receiving connections so fast that your loop is unable to keep up with them, there is no problem. (That is, it is a question of incoming connections per second, not the timing of any particular connection relative to your loop.)

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

Sidebar

Related Questions

This is more of a conceptual question than anything. I have a base class
This is a conceptual question involving Hadoop/HDFS. Lets say you have a file containing
I have an interesting situation here this time. This more of a conceptual question,
I have a conceptual question about photo galleries like this: http://www.nikesh.me/demo/image-hover.html If you open
I have a high-level/conceptual question about Shibboleth. I'm working on the front-end (running Drupal)
This is a conceptual question but I think it does have an 'answer', hopefully
this is more a conceptual question. Consider you have a php framework that runs
This is a very low-level, conceptual question. I have a content site where the
I have this conceptual question about ajax that I'm not sure if I understand.
I'm new to programming and I have a conceptual question. That is, can exception

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.