Re: socket.unbind or socket.unlisten? - socket.error: (48, 'Addressalready in use')

Discussion in 'Python' started by Steve Holden, Feb 1, 2009.

  1. Steve Holden

    Steve Holden Guest

    My previous reply assumed you are running some UNIX-like operating
    system. If you are on Windows then Jean-Paul's advice stands, as Windows
    *does* allow several processes to listen on the same port and randomly
    delivers incoming connections to one of the listening processes.

    I believe this is because Microsoft failed to understand the original
    meaning of SO_REUSEADDR for their early TCP implementations, and
    persisted with this ghastly error in the name of backwards
    compatibility, justifying it by suggesting that listener pools could be
    created. Or some such nonsense. Perhaps someone with more insight into
    the development process could comment. It seems to me it's completely
    bizarre.

    However, under Windows 2000 and later you should find there's an
    SO_EXCLUSIVEADDRUSE flag which you can use to ensure a single listener -
    see http://msdn.microsoft.com/en-us/library/ms740621(VS.85).aspx. No
    need for separate locks.

    regards
    Steve
     
    Steve Holden, Feb 1, 2009
    #1
    1. Advertisements

  2. Steve Holden

    Aahz Guest

    +1 QOTW
     
    Aahz, Feb 3, 2009
    #2
    1. Advertisements

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments (here). After that, you can post your question and our members will help you out.