diff --git a/bindings.py b/bindings.py index 9791544..20bb441 100755 --- a/bindings.py +++ b/bindings.py @@ -149,7 +149,7 @@ class analogController(object): self.sendData('#{}'.format(value)) ret=self.waitfor(_WAIT_STATUS) print(ret) - + def _keepAlive(self,val=1): """Send a keepalive to check (and ensure) the connection is still up [SYpig] Will return the invert of the value sent: 0x0000 0000 will return 0xFFFF FFFF @@ -268,11 +268,11 @@ class analogController(object): ##################### # TESTING if __name__ == '__main__': - + _HOSTS=[["127.0.0.1",10500]] # Test server ctrl1=analogController(*_HOSTS[0]) ctrl1.connectionSequence() - ctrl1.waitfor("") + # ctrl1.waitfor("") # except ConnectionRefusedError: # # Receive data # print('# Receive data from server') diff --git a/falseserver.py b/falseserver.py new file mode 100644 index 0000000..f2b81df --- /dev/null +++ b/falseserver.py @@ -0,0 +1,30 @@ +def sequenceAnswers(seq): + + +def Main(): + host = "127.0.0.1" + + # reverse a port on your computer + # in our case it is 12345 but it + # can be anything + port = 10500 + s = socket.socket(socket.AF_INET, socket.SOCK_STREAM) + s.bind((host, port)) + print("socket binded to port", port) + + # put the socket into listening mode + s.listen(5) + print("socket is listening") + + # a forever loop until client wants to exit + while True: + + # establish connection with client + c, addr = s.accept() + # Start a new thread and return its identifier + start_new_thread(sequenceAnswers, (sequence,)) + s.close() + + +if __name__ == '__main__': + Main()