summaryrefslogtreecommitdiff
path: root/example
diff options
context:
space:
mode:
Diffstat (limited to 'example')
-rw-r--r--example/socket.pl10
1 files changed, 10 insertions, 0 deletions
diff --git a/example/socket.pl b/example/socket.pl
new file mode 100644
index 0000000..41f87d7
--- /dev/null
+++ b/example/socket.pl
@@ -0,0 +1,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).