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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 12, 20262026-06-12T10:27:06+00:00 2026-06-12T10:27:06+00:00

Ok, so I have Python 2.5 and Windows XP. I was using select.select with

  • 0

Ok, so I have Python 2.5 and Windows XP. I was using select.select with a socket object. I tried it again and again, but whenever I run it, the thread it is in gives me an error like select.error(9, “Bad file descriptor”).
The code is something like this:

import socket, select
s = socket.socket()
s.bind((socket.gethostbyname(socket.gethostname()), 1312))
s.listen(5)
inputs = [s]
outputs = []
while True:
    r, w, e = select.select(inputs, outputs, inputs)
    for sock in r:
        if sock is s:
            inputs.append(s.accept()[0])
        else:
            print s
            print s.recv(1024)

Any info would be appreciated. Thanks!

  • 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-12T10:27:08+00:00Added an answer on June 12, 2026 at 10:27 am
    1. You called select.select with no arguments. It should be something like: select.select(inputs, outputs, []).

    2. In the else you need to use sock, not s (the server).

    3. Once the peer disconnects from a previously connected socket, you should remove it from the inputs list. You can know the peer has disconnected if sock.recv() returns an empty string or raises a socket.error exception. If you don’t do this, you might end up feeding an invalid socket descriptor to select.select, causing the error you talked about.

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

Sidebar

Related Questions

I want to take a screenshot using python. I have tried using PIL, but
I am using Python 2.7 on Windows XP. I have a simple python script
I have successfully created a Python Windows service using pywin32. In testing my application
I have python application that shoud be launched as windows executable. I'm using py2exe
I have been learning Python2.7 for a little bit now. I'm using Windows 7
Python novice here. I am using python2.7.2 on Windows7. I have installed the PyWin32
I have Python 2.7 running on Windows XP. I am trying to install Spynner
I have the python package in Cygwin on Windows 7. However, typing python -V
I have a python program that must work on Windows and Linux. There are
Anyone have a nifty trick (in Python) to detect Windows services that are configured

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.