Closing sockets does not free them

Lars Frantzen <[email protected]>
Newsgroups gmane.comp.gnu.prolog.general
Organization Radboud University Nijmegen
Message-ID <[email protected]>
Hi all,

I have written a simple server written in GNU Prolog opening a socket
for a client. After the job is done I close the streams and terminate
the program.

However, after terminating, the socket stays blocked for some time (like
2 minutes), I get a:

system_error(cannot_catch_throw(error(system_error('Address already in
use'),socket_bind/2)))

I am using it under a 64bit Linux. Is this normal behaviour or is there
something wrong with my code? To set up the socket I do:

	socket('AF_INET', Des),
	socket_bind(Des, 'AF_INET'(Host,Port)),
	socket_listen(Des, 1),
	socket_accept(Des, Client, StreamIn, StreamOut),

        repeat,
	read(StreamIn, Query),
	...
	write(StreamOut, Solution),
        fail.

To close the connection I do:

	close(StreamIn),
	close(StreamOut)

I also tried adding a:

	socket_close(Des)

But that did not help.

The full source is here:
http://www.cs.ru.nl/~lf/tools/treesolver/treeSolver.pl

Thanks for all hints, and cheers,
Lars
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.