-2
Hello!
I’ve been trying to learn about python socket. My first code would be a program to connect a client to a server and then send data. I put the python file on the server side on another computer in my house.
Here’s part of the client-side:
import socket
HOST = "localhost"
PORT = 5000
tcp = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
dest = (HOST, PORT)
print("Conectando...")
tcp.connect(dest)
And here’s the server-side part:
HOST = socket.gethostname()
print(HOST)
PORT = 5000
threads = {}
tcp = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
orig = (HOST, PORT)
tcp.bind(orig)
tcp.listen(5)
con, cliente = tcp.accept()
Here is the error I get. I believe this is related to the host:
tcp.connect(dest) Connectionrefusederror: [Winerror 10061] No connection could be made because the destination machine actively refused them
I tried to put in the client-side host variable the ip of my machine - server - and apparently there is no answer.
Using
HOST = "0.0.0.0"
and on the client side using the server ip: No server response. Already when using HOST = "localhost" on the client side says the server refused.– Thunder - 41
Using on the server
HOST = "localhost"
and on the customerHOST = "localhost"
server refused. Already using clientHOST = "ip do servidor"
there was no response.– Thunder - 41
It looks like a permission issue in the firewall. If you are using Windows (it seems to be due to the error), open a
cmd e rode o seu server; depois abra outro
cmdcomo administrador, e rode
netstat -a -b`; check that the TCP 5000 port is LISTENING.– Paulo Marques
https://prnt.sc/10r4f87 That’s right, it’s in Listening.
– Thunder - 41
Agita has to see the firewall...
– Paulo Marques