Here is the code I used for the TCP/IP communication and the method for sending ur script. Is it because I am sending the script as a string? Please let me know if any of you have some insight. thanks!
// localhost IP
private String TCP_IP = “127.0.0.1”;
// Port for secondary client
private int TCP_port = 30002;
public void sendClose(String whichOut, String signal1){
sendToSecondary("set_tool_digital_out("+whichOut+", "+signal1+")");
}
public void sendOpen(String whichOut2, String signal2){
sendToSecondary("set_tool_digital_out("+whichOut2+", "+signal2+")");
}
private void sendToSecondary(String command){
try{
Socket sc = new Socket(TCP_IP, TCP_port);
if (sc.isConnected()){
System.out.println("Connected to UR Secondary Client");
}
DataOutputStream out;
out = new DataOutputStream(sc.getOutputStream());
String thisCommand = "def myCustomCode():\n "+command+"\n end\n";
out.writeUTF(thisCommand);
System.out.println("Send this: "+thisCommand);
out.flush();
out.close();
sc.close();
System.out.println("Disconnected from UR Secondary Client");
}
catch (IOException e){
System.out.println(e);
}
}
}