Python and Socket not responding

Hello all!

I am trying to query my timers via a simple python script.
import socket

TCP_IP = '192.168.1.101'
TCP_PORT = 2101
BUFFER_SIZE = 1024
MESSAGE = 'AA03E96A03'.decode('hex')
print MESSAGE
s = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
s.connect((TCP_IP, TCP_PORT))
s.send(MESSAGE)
data = s.recv(BUFFER_SIZE)
s.close()

print "received data:", data

Unfortunately when i run it i get the following output

PS C:\Users\teknix\Cooker\ncd-fusion-client> python.exe .\main.py
¬Θj
Traceback (most recent call last):
  File ".\main.py", line 10, in <module>
    s.connect((TCP_IP, TCP_PORT))
  File "C:\Python27\lib\socket.py", line 228, in meth
    return getattr(self._sock,name)(*args)
socket.error: [Errno 10061] No connection could be made because the target machine actively refused it

any idea why it would deny me?

Hi,

It’s possible the connection is failing because the IP address is incorrect or because other software is already connected to the board. Keep in mind the board only allows 1 TCP socket connection at a time so if you have something like NCD Base Station or N Button software connected your Python script will not be able to connect to the board.

Thank you Travis, I had totally spaced the connection limit lol
That will teach me for posting later in the day :slight_smile:

No problem. Let us know if you need anything else.