diff options
author | Benjamin Franzke <benjaminfranzke@googlemail.com> | 2012-11-08 14:42:38 +0100 |
---|---|---|
committer | Benjamin Franzke <benjaminfranzke@googlemail.com> | 2012-11-08 14:44:23 +0100 |
commit | fa6e98d8ecf58d4ad4144636f58820d9102695c4 (patch) | |
tree | b6b90099193e9fb84acb5222daf4fb78720d4560 | |
parent | 85a747753b52a47be9c3a9ecf53d1dfd940e36fb (diff) | |
download | wbs-fa6e98d8ecf58d4ad4144636f58820d9102695c4.tar.gz wbs-fa6e98d8ecf58d4ad4144636f58820d9102695c4.tar.bz2 wbs-fa6e98d8ecf58d4ad4144636f58820d9102695c4.zip |
Add an example on how to connect, write and read from a socket with GNU Prolog
-rw-r--r-- | example/socket.pl | 10 |
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). |