'Address already in use' ... with TCPServer
Giampaolo Rodola'
gnewsg at gmail.com
Fri Jan 30 07:16:42 EST 2009
On 30 Gen, 10:16, "Gabriel Genellina" <gagsl-... at yahoo.com.ar> wrote:
> En Fri, 30 Jan 2009 05:43:33 -0200, Mabooka-Mabooka Mbe-Mbe
> <ochichinyezaboom... at yahoo.com> escribió:
>
> > setsockopt(REUSEADDR)...
>
> > What I came up with so far is this:
> >>>> from SocketServer import *
> >>>> s = TCPServer( ('', 32123), None)
> >>>> dir(s)
> > ['RequestHandlerClass', '__doc__', '__init__', '__module__',
> > 'address_family', 'allow_reuse_address', ... ]
>
> > Aha! My bet is (was):
> >>>> s.allow_reuse_address=1
> > should do the trick.
>
> It's too late then; bind() has already been called. The easiest way is to
> define your own derived class:
>
> import SocketServer
>
> class TCPServer(SocketServer.TCPServer):
> allow_reuse_address = True
>
> s = TCPServer(...)
What's even faster is setting the class attribute right after the
module import:
>>> import SocketServer
>>> SocketServer.TCPServer.allow_reuse_address = True
--- Giampaolo
http://code.google.com/p/pyftpdlib
More information about the Python-list
mailing list