Socket error 98 "Address already in use"

Grant Edwards invalid at invalid.invalid
Thu Jun 17 20:59:56 EDT 2010


On 2010-06-18, AK <ak at nothere.com> wrote:

> Here it is:
>
> Traceback (most recent call last):
>   File "./vimp3_player.py", line 112, in <module>
>     Player().main()
>   File "./vimp3_player.py", line 35, in main
>     self.listen()
>   File "./vimp3_player.py", line 41, in listen
>     s.bind((HOST, PORT))
>   File "<string>", line 1, in bind
> socket.error: [Errno 98] Address already in use

Setting the SO_REUSEADDR option should prevent that, and in my
experience it always does.  What OS are you using?

Is there some reason you want to rebind each time?  Why not just loop
around the conn,addr = accept() .... con.close() section?

> It'd be a bit difficult to separate it, I was hoping this is a known
> issue and this description would be enough, but if that turns out not to
> be the case I'll make a minimal working example.

It is a known issue, but it's solved by setting the REUSEADDR option
on the socket before calling bind().  Are you sure you don't somehow
leave a server running on that port that prevents the bind() from
working?

-- 
Grant




More information about the Python-list mailing list