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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T20:45:00+00:00 2026-05-26T20:45:00+00:00

For some reason I cannot match select sockets to my dictionary of sockets. The

  • 0

For some reason I cannot match select sockets to my dictionary of sockets. The below code creates a dictionary of sockets (which is does) then when someone connects accept (which it doesn’t). It finds ‘s’ in ‘L’, but then cannot socket.error: [Errno 22] Invalid argument

listening = {}
L = []
for link in links:
    try:
        # listening
        listening[link] = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
        listening[link].bind((host, routers[routername].baseport+links[link].locallink))
        listening[link].listen(backlog)
        # append routes and listen-list
        L.append(listening[link])
    except socket.error, (value,message):
        print "Could not open socket: " + message
        sys.exit(1)

# run loop
input = L
running = 1
while running:
    inputready,outputready,exceptready = select.select(input,[],[], 0)

    # Sockets loop
    for s in inputready:
        if s in L:
            # handle the server socket
            client, address = s.accept()
            input.append(client)
  • 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-26T20:45:01+00:00Added an answer on May 26, 2026 at 8:45 pm

    Although unsure of all my wrongs in the first attempt, I have since solved my own dilema. @Jeremy was on the right track, but slightly off (probably due to my description). The sockets don’t get referenced outside of s and therefore do not need to be a dictionary. However, select only takes a list so rather than complicating things with other data types, stick with a list and reference s instead of L (s is what you want anyways)

    L = []
    input = [sys.stdin]
    
    for i in range(4):
        server = socket.socket(socket.AF_INET, socket.SOCK_STREAM) 
        server.bind((host,port+i)) 
        server.listen(backlog)
        L.append(server)
        input.append(server)
    
    running = 1
    print len(L)
    while running: 
        inputready,outputready,exceptready = select.select(input,[],[]) 
    
        for s in inputready: 
            if s in L: 
                # handle the server socket
                print "opened"
                client, address = s.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)
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

for some reason I cannot see any of the generated objects under the TL
It's a common problem, solved many times, but for some reason i cannot find
For some reason, no matter how I go about it, I cannot get TortoiseSVN
I have some classes that, for one reason or another, cannot be or need
for some reason my play eclipse app cannot run a bootstrap job and throws
I need to write a regex but for some reason i cannot get the
For some reason I cannot get this to work for the life of me,
For some reason I cannot get my SlideToggle to work. My list 'tellusmore' is
For some reason I cannot use render in a one line conditional. Example, this
I am trying to get a class working but for some reason I cannot

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.