closing a socket

William Annis annis at biostat.wisc.edu
Thu Jul 20 12:04:04 EDT 2000


Keith Murphy <kpmurphy at my-deja.com> writes:

> is closing sockets tricky? or am i doing something wrong...  shouldn't
> this work?

        There is one small thing you need, something every sockets
beginner misses at first.  I know I did...

> s = socket(AF_INET, SOCK_STREAM)

        You need the set the 'reuse address' option:

        s.setsockopt(SOL_SOCKET, SO_REUSEADDR, 1)

> however, i get the following error if i try and run it a second time:
> 
> socket.error: (125, 'Address already in use')

-- 
William Annis - System Administrator - Biomedical Computing Group
annis at biostat.wisc.edu                       PGP ID:1024/FBF64031
Mi parolas Esperanton - La Internacian Lingvon  www.esperanto.org



More information about the Python-list mailing list