Low-level Prolog to Java socket connection
Author(s): Jesús Correas.
This module defines a low-level socket interface, to be used by javart and jtopl. Includes all the code related directly to the handling of sockets. This library should not be used by any user program, because is a very low-level connection to Java. Use javart (Prolog to Java interface) or jtopl (Java to Prolog interface) libraries instead.
Usage and interface
- Library usage:
:- use_module(library(javasock)). - Exports:
- Imports:
- System library modules:
fastrw, sockets/sockets, format, concurrency/concurrency, javall/jtopl, sockets/sockets_io. - Packages:
prelude, nonpure, assertions, regtypes, isomodes.
- System library modules:
Documentation on exports
Usage:bind_socket_interface(Port)
Given an port number, waits for a connection request from the Java side, creates the sockets to connect to the java process, and starts the threads needed to handle the connection.
- Call and exit should be compatible with:
(basic_props:int/1)Port is an integer. - The following properties should hold at call time:
(term_typing:nonvar/1)Port is currently a term which is not a free variable.
Usage:start_socket_interface(Address,Stream)
Given an address in format 'node:port', creates the sockets to connect to the java process, and starts the threads needed to handle the connection.
- Call and exit should be compatible with:
(basic_props:term/1)Address is any term.
(streams_basic:stream/1)Stream is an open stream. - The following properties should hold at call time:
(term_typing:nonvar/1)Address is currently a term which is not a free variable.
(term_typing:nonvar/1)Stream is currently a term which is not a free variable.
Usage:
Closes the sockets to disconnect from the java process, and waits until the threads that handle the connection terminate.
Usage:
Waits until the threads that handle the connection terminate.
Usage:java_query(ThreadId,Query)
Data predicate containing the queries to be sent to Java. First argument is the Prolog thread Id, and second argument is the query to send to Java.
- Call and exit should be compatible with:
(basic_props:atm/1)ThreadId is an atom.
(basic_props:term/1)Query is any term.
Usage:java_response(Id,Response)
Data predicate that stores the responses to requests received from Java. First argument corresponds to the Prolog thread Id; second argument corresponds to the response itself.
- Call and exit should be compatible with:
(basic_props:atm/1)Id is an atom.
(basic_props:term/1)Response is any term.
Usage:prolog_query(Id,Query)
Data predicate that keeps a queue of the queries requested to Prolog side from Java side.
- Call and exit should be compatible with:
(basic_props:int/1)Id is an integer.
(basic_props:term/1)Query is any term.
Usage:prolog_response(Id,Response)
Data predicate that keeps a queue of the responses to queries requested to Prolog side from Java side.
- Call and exit should be compatible with:
(basic_props:int/1)Id is an integer.
(basic_props:term/1)Response is any term.
Usage:
Starts the threads that will handle the connection to Java. This predicate is declared public for internal purposes, and it is not intended to be used by a user program.