Send request from robot controller to computer with socket communication or others

I would like to know how to send an “R1” request for example, from the robot controller to a computer. A python program would take care of retrieving this request. I thought maybe to use the “socket” but I don’t know which script command to use on the teach and on my python program.
I have with me a UR 16 e-series.