Hi everyone,
I am working with KUKA LBR iiwa by using SunRise Workbench and I need to connect the robot with another device using a TCP/IP protocol. I am writing a TCP/IP server and a TCP/IP client using java sockets. Actually, when I use the robot as the server, I am able to establish a connection using my laptop as client. But when I try the opposite task (robot-client and laptop-server), it says "Connection timed out: connect".
Is there anyone who can give me any advise?
Thanks in advance,
Here is the client code:
public class LBR_Client {
private PrintStream out = null;
private BufferedReader in = null;
@Override
public void initialize() {
Socket socket = null;
try {
socket = new Socket("172.31.1.14", 30001);
in = new BufferedReader(new InputStreamReader(socket.getInputStream()));
out = new PrintStream(new BufferedOutputStream(socket.getOutputStream()), true);
out.println("client message");
System.out.print("server message: " + in);
out.close();
in.close();
socket.close();
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
@Override
public void run() {
}
}
And here's the server code:
public class MyServer {
public static void main(String args[]) throws IOException{
Socket client;
BufferedReader in = null;
PrintStream out = null;
try {
ServerSocket server = new ServerSocket(30001);
client = server.accept();
server.close();
in = new BufferedReader(new InputStreamReader(client.getInputStream()));
out = new PrintStream(new BufferedOutputStream(client.getOutputStream()), true);
BufferedReader stdIn = new BufferedReader(new InputStreamReader(System.in));
String userInput;
userInput = stdIn.readLine();
out.println(userInput);
System.out.print("Client message: " + in);
stdIn.close();
out.close();
in.close();
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
}