Socket communications

hello all,
im currently working in ur5 cobot
I tried to move the cobot ur5 with python sockets by below program

import socket
import time
host=‘192.168.10.2’
port= 30002
s=socket.socket(socket.AF_INET,socket.SOCK_STREAM)
s.setsockopt(socket.SOL_SOCKET, socket.SO_REUSEADDR, 1)
s.connect((host,port))
msg=s.recv(1024)
print(msg)
s.send(“set_digital_out(0,True)”.encode())
time.sleep(1)
data=s.recv(1024)

When i execute the above code i can receive the data but when i execute script command, i cant see any responses from the cobot. Could you please tell anyone the major root cause for the issue. and it would be very helpful for me.
Thanks!

The port 30002 is the secondary interface, which is only for data. See this from the client interfaces support page:

UR controller provide servers to send robot state data and receive URScript commands. The primary interface transmits robot state data and additional messages. The secondary interface transmits robot state data only.

Try to change to port 30001

Thankyou for your time and detailed response.
I’ve just tried by adding ‘\n’ newline at the end of the script command, somehow it is working fine.
Thanks again for your response!!