socket.unbind or socket.unlisten? - socket.error: (48, 'Addressalready in use')
Hendrik van Rooyen
mail at microcorp.co.za
Mon Feb 2 02:57:23 EST 2009
"Steve Holden" <st. at hol.eb.com> wrote:
>
> 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.
>
Thanks Steve - I am not the OP, I was just curious as to why
Jean-Paul was saying what he did - so the only reason I have
not been bitten on windoze yet must be either because I am
lucky, or because my server side stuff is linux and there is the
occasional windows client. So I don't really listen on windows.
"a pool of listeners" - just think of the fun one can have trying to
keep state between them - would be a marvellous job if someone
else is paying top dollar by the hour - I can just see the team growing
as the need for new specialists are discovered as one goes along.
:-)
- Hendrik
More information about the Python-list
mailing list