xmlrpc tutorial?

Stephen Coursen talon at www.tempestnetworks.net
Fri Nov 30 11:52:43 EST 2001


On Fri, 30 Nov 2001 17:45:23 +0100, Carsten Gaebler <clpy at snakefarm.org> wrote:
>talon at www.tempestnetworks.net wrote:
>> 
>> On Fri, 30 Nov 2001 15:22:21 +0100, Carsten Gaebler <clpy at snakefarm.org> wrote:
>>
>> >However, there seems to be a problem with restarting the server. I
>> >have to wait a minute or so to avoid an 'address is already in use'
>> >error.
>> 
>> Use the setsockopt function on the socket objet, pass it the value
>> SO_REUSEADDR (defined in the socket module).
>
>Nope, doesn't help. My code is:
>
>server = SocketServer.TCPServer(('', 8000), TestRequestHandler)
>server.socket.setsockopt(socket.SOL_SOCKET, socket.SO_REUSEADDR, 1)
>server.serve_forever()
>
>cg.

Ah ha, the problem is due to how you're using TCPServer.  Try:

SocketServer.TCPServer.reuse_address = 1
server = SocketServer.TCPServer( ('', 8000), TestRequestHandler )
server.serve_forever( )

The problem is that the socket is bound (TCPServer.__init__ calls
server_bind( )), it logically follows that you have to set this particular
socket option before the socket is bound :)

HTH,
Steve

>-- 
>'In iteger arithetric divsion is no the oposite of multiplication.'
>                                   -- scenes from comp.lang.python


-- 
--

Visits always give pleasure: if not on arrival, then on the departure.
		-- Edouard Le Berquier, "Pensees des Autres"



More information about the Python-list mailing list