Socket error 98 "Address already in use"

AK ak at nothere.com
Thu Jun 17 19:28:34 EDT 2010


On 06/17/2010 07:21 PM, AK 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
> 
> 
> .. and on client:
> 
> 
>     HOST = ''
>     PORT = 50025
>     s = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
>     s.setsockopt(socket.SOL_SOCKET, socket.SO_REUSEADDR, 1)
>     s.connect((HOST, PORT))
> 
> 
> Thanks! -ak


I forgot to add that I'm on Ubuntu 9.10 and using python 2.6. -ak



More information about the Python-list mailing list