summaryrefslogtreecommitdiff
path: root/example/socket.pl
blob: 41f87d7aa51801fcbddf6f09a0146c1d1a0498ae (plain)
1
2
3
4
5
6
7
8
9
10
start:-start(localhost).
start(Host):-start(Host, 8068).

start(Host,Port):-
socket('AF_INET', Socket),
hostname_address(Host, HostAddress),
socket_connect(Socket, 'AF_INET'(HostAddress, Port), StreamIn, StreamOut),
write(StreamOut, c), flush_output(StreamOut),
read_atom(StreamIn, X), write(X), nl,
socket_close(Socket).