Hello,
i am trying to do a commucation between Cobot and PC with python.
For that I wrote a Python script …
import socket
s = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
s.setsockopt(socket.SOL_SOCKET, socket.SO_REUSEADDR, 1)
HOST = "192.168.41.42"
PORT = 30000
s.bind((HOST, PORT))
s.listen(1)
try:
while True:
komm, addr = s.accept()
while True:
data = komm.recv(1024)
if not data:
komm.close()
break
print("[{}] {}".format(addr[0], data.decode()))
nachricht = input("Antwort: ")
komm.send(nachricht.encode())
finally:
s.close()
On my cobot I tried to connect with server_open(“192.168.41.42”, 30000, “socket”)
Somehow the connection doesn’t work.
komm, addr = s.accept() The program on the PC doesn't get past this point.
server_open(“192.168.41.42”, 30000, “socket”) The program on the cobot can't connect via this command
but the Network connection is possible. Because I can ping the cobot from the PC.
Can anyone tell me what I am doing wrong?
Thank you!!