SOAPpy port reuse

Piet van Oostrum piet at cs.uu.nl
Sun Nov 18 09:44:45 EST 2007


>>>>> Maurice LING <mauriceling at acm.org> (ML) wrote:

>ML> Hi,
>ML> I have a problem:

>ML> 1. Assuming that my application is a SOAP server that uses SOAPpy,
>ML> 2. I am given port 35021 for use.

>ML> What I normally do (simply) is:

>ML> functionlist = [<some exposed functions>]
>ML> import SOAPpy
>ML> server = SOAPpy.SOAPServer((<some host>, 35021))
>ML> for func in functionlist: server.registerFunction(func)
>ML> server.serve_forever()

>ML> My question is: How can I shutdown this server and reuse port 35021 when my
>ML> functionlist changes?

>ML> Currently, after killing the python process which runs this SOAP server,
>ML> the port (35021 in this case) cannot be re-used, as though it is still
>ML> phantom-ly bounded to some process (which should have been killed).

This phenomenon is explained here:
http://hea-www.harvard.edu/~fine/Tech/addrinuse.html
or the Unix socket FAQ (http://www.faqs.org/faqs/unix-faq/socket/) 2.7

Normally the solution is to set the SO_REUSEADDR option in the socket (the
original one) before binding it:
s.setsockopt(socket.SOL_SOCKET,socket.SO_REUSEADDR,1)

However, SOAPPy does that already so it should work.
-- 
Piet van Oostrum <piet at cs.uu.nl>
URL: http://www.cs.uu.nl/~piet [PGP 8DAE142BE17999C4]
Private email: piet at vanoostrum.org



More information about the Python-list mailing list