Socket struggles...

Torbjörn Lager lager at ling.gu.se
Sun Aug 4 19:32:41 CEST 2002


Hi All,

I want to set up a socket connection between an existing Java program
(client) and an Oz program (server). The client sends one (sometimes
fairly large) text string to the server. The server does some processing
on it and sends back the result (also a string, fairly large). The
client may send new string before the server has finished processing the
old one. I have read the documentation for sockets (in the Open 
Programming doc), read some relevant stuff in the mailing list
archives, and experimented a bit, but I'm still not sure how to this in
the best possible way. In fact, I can't get bidirectional communication 
to work at all :-(

In the following programs I simulate the Java client by an Oz program:

The server (in one OPI window):

declare

class Accepted from Open.socket
    meth getInfo($)
       {self read(list:$ size:all)}
    end
end

proc {Accept}
    A
in
    {Server accept(acceptClass:Accepted
		  accepted:?A)}
    {Browse thread {A getInfo($)} end}
    {Browse 'reached this point'}
    {Server flush}
    {Server write(vs:"Hello client!\n")}
    {Server flush}
    {Accept}
end

Server = {New Open.socket init}
{Server bind(host:localhost takePort:4096)}
{Server listen}
{Accept}


The client (in another OPI window):

declare

C1={New Open.socket client(host:localhost port:4096)}
{C1 write(vs:"Hello server!\n")}
{C1 flush}
{Browse thread {C1 read(list:$ size:all) } end }


The server receives the message from the client, but the server's 
response isn't received by the client. I'm sure there are things I don't 
understand here... Please help!

Cheers,
Torbjorn

-
Please send submissions to users at mozart-oz.org
and administriva mail to users-request at mozart-oz.org.
The Mozart Oz web site is at http://www.mozart-oz.org/.





More information about the mozart-users mailing list