|
From: | carlos calderon |
Subject: | Newbie: redundant connection |
Date: | Sun, 17 Jun 2001 13:20:58 +0100 |
Hi all,
First off, sorry if I am over using the list with
what are probably dull questions for some of you. but you've really helped, so
thank you very much.
Now onto the question:
I wrote the following piece of code:
/*Solution is a list*/
sendlist(Solution)
:-
/*create
sockets*/
socket('AF_INET',Socket),
/*connect
to server*/
socket_connect(Socket,'AF_INET'('152.xxx.xxx.xxx',
1936), StreamInput,StreamOuput),
/*where
xxx is my server's IP
address*/
set_stream_buffering(StreamOutput,none),
'$stream'(I)
= StreamOutput,
write2server(Solution,'$stream'(I)),
/*close
socket*/
socket_close(Socket).
My
problem is that when I try to send the first solution to the server it works
fine:
-create
socket,
-connect
to server
However
for subsequent solutions, "obviously" generates a redundant connection attempt
(socket_connect).
I
guess what I need it's something
like:
connection=false
If
connection=false
then
-create
socket
-connect
to server
connection
= true
.
.
Alternatively, I think I could do with a predicate
like:
socket_destroy(Socket)
to the destroy the socket.
In the manual, pag 153, recommends to use close/2
to close the associated stream.
I've tried that but it doesn't work for me, I still
get a redundant connection.
Any ideas about how to get around this?
Thanks
|
[Prev in Thread] | Current Thread | [Next in Thread] |