[Tutor] seeking help to a problem w/ sockets

Alan Gauld alan.gauld at btinternet.com
Sun Apr 27 09:40:39 CEST 2008


"James Duffy" <devsfan1830 at gmail.com> wrote

> works. However, if the program that is using this function is closed 
> while
> listening, it appears that it does not "un-bind" because when the 
> program is
> reopened and a listen attepted to start I get a "port already in 
> use" error.
> Only a reboot fixes this issue.

You don;t say what OS you are using but I have had this problem
on *nix boxes where the socket/port is represented by a file in /tmp
and you need to go in and kill the file manually(or by a script of 
course)
before you can reopen the socket.

If its not *nix then you may have to look at a similar fix on your
OS - maybe in the registry of Windows for example.

> the listen and close the connection and socket. I basically need to 
> get to
> the close function and then stop the while loop. Thanks in advance 
> for any
> help anyone can give. My code for the listener class follows:

I haven't read the code, sorry, but could you use a try/finally 
wrapper
around your threads?

Just a thought,


-- 
Alan Gauld
Author of the Learn to Program web site
http://www.freenetpages.co.uk/hp/alan.gauld 




More information about the Tutor mailing list