1
I tried to make a Python 3.5.1 socket, but when I went to test it only connects with me. I tried to connect to another computer (from my friend), but it does not connect. Does anyone know how to make a socket that actually connects?
In case anyone wants to see, here’s my troublesome socket: http://pastebin.com/Z01Fp71K
#Cliente
import socket
HOST = 'Aqui eu coloco o ip'
PORT = 5000
tcp = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
dest = (HOST, PORT)
tcp.connect(dest)
print('Para sair use CTRL+X\n')
msg = input()
while msg != '\x18':
tcp.send(msg)
msg = input()
tcp.close()
#Servidor
import socket
HOST = ''
PORT = 5000
tcp = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
orig = (HOST, PORT)
tcp.bind(orig)
tcp.listen(1)
while True:
con, cliente = tcp.accept()
print('Concetado por', cliente)
while True:
msg = con.recv(1024)
if not(msg): break
print(cliente, msg)
print('Finalizando conexao do cliente', cliente)
con.close()
If it worked for you it’ll probably work for your friend too. What must be happening is that port 5000 must be blocked in your friend’s PC firewall. Search for how to free ports in the Windows firewall (or other operating system) you have on your PC.
– Piovezan
Yes I researched it and it still doesn’t work
– Rodrigo Damasceno