users-prolog
[Top][All Lists]
Advanced

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

Re: Socket communication between GNU prolog and Java.


From: Vic Bancroft
Subject: Re: Socket communication between GNU prolog and Java.
Date: Fri, 21 Mar 2003 02:30:52 -0500 (EST)

On Thu, 20 Mar 2003 address@hidden wrote:

> I have written two short test programs modeled upon code in the CLPGUI 
> application.

The choice of port is what leads to your system error on the socket
bind.  Unless you are running the program as root, your choice of port 
should be above 1024.  A happier choice of ports is simply,

  socket_bind(NbSocket,'AF_INET'(localhost,1025)),

This can be run without root permissions.  Another exception I had was

  error(system_error('Address already in use'),socket_bind/2)

These exceptions might encourage one to use catch/3 around the read/2 call.

> The client (Java program) sends a message to the server, hello, and the 
> server should return the message back to the client. 

You might be surprised by the new output of the java program, 

  $ java JavaToGP
  _25

This occurs because the read/2 predicate expects prolog syntax. The string
"Hello." will read as a prolog variable.  If you change the java program to 
use, out.println("hello."); the output is the expected prolog atom,

  $ java JavaToGP
  hello

If you want to communicate over the socket without requiring messages
to be well formed prolog syntax, the predicates for character or byte 
input / output might be more suitable.  On the other hand, if your intent 
is to stream prolog queries and responses, read_term/3 is often handy!

more,
l8r,

------------------------------------------------------------------- 
Victor Bancroft, Principal Engineer, Zvolve Systems [v]770.551.4505 
1050 Crown Pointe Pkwy, Suite 300, Atlanta GA 30338 [f]770.551.4509 
Fellow, Artificial Intelligence Center              [v]706.542-0358 
Athens, Georgia  30602, U.S.A           http://ai.uga.edu/~bancroft 





reply via email to

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