[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Closing sockets does not free them
From: |
Lars Frantzen |
Subject: |
Closing sockets does not free them |
Date: |
Tue, 01 Sep 2009 17:41:28 +0200 |
User-agent: |
Thunderbird 2.0.0.23 (X11/20090817) |
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
- Closing sockets does not free them,
Lars Frantzen <=