Socket error 98 "Address already in use"

Grant Edwards invalid at invalid.invalid
Thu Jun 17 20:19:25 EDT 2010


On 2010-06-17, AK <ak at nothere.com> wrote:
> Hi, I'm trying to make a little mp3 server / client and I'm running into
> a problem with the Socket error 98 "Address already in use". The error
> doesn't happen right away, I can send 3-4 commands, disconnecting and
> reconnecting and they work fine and then I get this error and the client
> can no longer connect, although the client side doesn't get any errors.
> Here's the relevant code:
>
>         s = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
>         s.setsockopt(socket.SOL_SOCKET, socket.SO_REUSEADDR, 1)
>         s.bind((HOST, PORT))
>         s.listen(1)
>         conn, addr = s.accept()
>         try: self.player(conn, addr)
>         except: pass
>         conn.close()
>         s.close()
>         del s

Always, always, always: post the traceback.

If that's your server code, I don't see how you can disconnect and
reconnect.  That code only accepts a single connection, then it's done.

Also always: post minim but real code the shows the problem.

-- 
Grant




More information about the Python-list mailing list