users-prolog
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Socket woes...


From: Sean Charles
Subject: Socket woes...
Date: Sat, 20 Jul 2013 23:08:07 +0100

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?


reply via email to

[Prev in Thread] Current Thread [Next in Thread]