Hi I am doing a project that I want to make Raspberry pi and Pc communicate and then Pc can get pulse signal sent from raspberry pi. The first step I think to do is to write a python server on raspberry pi side, and a client on windows side. Is it possible to get signal in this way?
and this is the code that I get from internet
The server :
import socket
s = socket.socket()
host = socket.gethostname()
port = 12345
s.bind((host, port))
s.listen(5)
while True:
c, addr = s.accept()
print ('Got connection from',addr)
c.send('Thank you for connecting')
c.close()
and the client :
import socket
s = socket.socket()
host = socket.gethostname()
print (host)
port = 12345
s.connect((host, port))
print (s.recv(1024))
s.close
But there is an error :
**Traceback (most recent call last):
File "C:\Python33\SimpleClient.py", line 9, in <module>
s.connect((host, port))
ConnectionRefusedError: [WinError 10061] No connection could be made because the target machine actively refused it**
I don't know what's wrong with it. Please help me :roll: Any answer are greatly accepted! Big thanks !!