Hi,
I would like to send urscript to sendoary port (30002) and open a socket and send data to another port (eg 11111). The program is not running, when I would like to send.
My code is:
Socket s = new Socket(“127.0.0.1”, 30002);
if(s.isConnected())
System.outprintln(“ok”);
DataOutputStrem out = new DataOutputStream(s.getOutputStream());
String cmd = “def codea():\n”
+"\tsocket_open(“192.168.1.127”, 11111)\n"
+"\tsocket_send_string(“oksend”)\nend\n";
out.writeUTF(cmd);
out.flush();
out.close();
s.close();
But its only connected to 11111 when a robot program is running. I would like to connect, when the robot program is stopped.
Another problem is it isnt send oksend string, only connect.
Having no connection (the code not being executed) using the other method could be an indication for some typo. Adding a popup or similar in the script code could help you exclude this possibility.
Using a while-loop to assure you, that the connection is established before the program continues, could also help out.