Socket woes...

Sean Charles <[email protected]>
Newsgroups gmane.comp.gnu.prolog.general
Message-ID <[email protected]>
Using this code to start and stop a session:

session_start(Port) :-
        socket('AF_INET', S),
        socket_bind(S, 'AF_INET'(localhost, Port)),
        socket_listen(S, 0),
        socket_accept(S, Client, In, Out),
        format(Out, "~n~n>> Welcome to SKYNET, ~w~n", [Client]),
        cmd_loop(In, Out),
        close(In),close(Out),socket_close(S),
        format("Clean close~n", []).

I've done lots of socket coding with PHP and C/C++ and usually the safest bet is to get the client to terminate the connection first to avoid and issues within the TCP driver regarding wait states and things but being new to prolog still I wonder if I've done something silly in my code that I can't see?

I am using telnet to connect, all foes well until I type "bye". The program terminates, tells me it was a clean close but when I try to run again:

session_start(10000).
uncaught exception: error(system_error('Address already in use'),socket_bind/2)

Bummer.

Any suggestions?

_______________________________________________
Users-prolog mailing list
[email protected]
https://lists.gnu.org/mailman/listinfo/users-prolog
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.