views:

242

answers:

2

I'd like to establish a server(Java)/client (Matlab) communication using socket. They can send messages to each other. An example shows how to do this in Java server and Java client, http://java.sun.com/docs/books/tutorial/networking/sockets/clientServer.html.

When I try to rewrite the client part in Matlab, I only can get the first message that the Java server sends and display it in the Matlab command window.

When I type a message in the Matlab command window, I can't pass it to the Java Server.

Jave code:

kkSocket = new Socket("localhost", 3434);

Matlab equivalent:

kkSocket = Socket('localhost', 3434);

Java code for client:

    out = new PrintWriter(kkSocket.getOutputStream(), true);
    in = new BufferedReader(new InputStreamReader(kkSocket.getInputStream())); 

What would be a Matlab equivalent for this? Thanks in advance.

+1  A: 

For the input stream:

input_stream   = input_socket.getInputStream;
d_input_stream = DataInputStream(input_stream);

For the output stream:

output_stream   = output_socket.getOutputStream;
d_output_stream = DataOutputStream(output_stream);
Geodesic
Thanks. I just replaced "output_socket" with input_socket.
A: 

did you have a look at the input stream of your socket? i think the issue lies here dear user275287