Socket Server in Python Accepts client but socket_open=False

Hello All,

I am trying to transfer some data from the robot to a csv file for evaluation at a later point ( data would be strings or floats). I have had success with the python RTDE record example on port 30004 to generally test communication and the ability to pass data, but this interface is really not what I need as I am trying to only pass a few values at specified parts of the program. My problem is that my server accepts the robot as a client, but socket_open(,30004,Socket_name) returns false, even after the server accepts the client. This seems to indicate the client(robot) cannot open communication to the server on this socket) Any help is greatly appreciated, below is the code I am trying to use

Thanks for your help
Dan Hinckley

My server is as below

import csv
HOST = ‘’ # Server IP address
PORT = 30000 # Port to use from UR example

import socket
import time
#Counter for max samples
count = 0
#Sampling loop
while (count < 1000):
s = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
s.setsockopt(socket.SOL_SOCKET, socket.SO_REUSEADDR, 1)
s.bind((HOST, PORT)) # Bind to the port
s.listen(5) # Now wait for client connection.
c, addr = s.accept() # Establish connection with client.
msg = c.recv(1024)
if msg (‘Data Ready’):
print ('the count is '+count)
except socket.error as socketerror:
print (‘Connection lost’+str(count))

Client side on robot looks like below:
(in main program have calls to run each step (SetupInterface(),InitComm() SendData()
the robot waits forever in the while loop for connected to be true

def SetupInterface():

Pass parameters to global variables.

global PC = “PC”
global IP = “”
global UsePort = 30000


def SendData():
global passloop=0
while passloop < 1000:
socket_send_string(“Data Ready”, PC)

def InitComm():
# Open the connection.
global connected = False
while (not connected):
global connected = socket_open(IP, UsePort,PC) # Establish connection to Pc
varmsg(“connected”, connected)
return connected