pythonsocketsnetwork-programminghamachi

Is It possible to connect to socket server using hamachi?


Is It possible? I wrote a code using socket library. Everything works fine on local network but when I try to connect using hamachi IP I get [WinError 10060]

Sample of server code:

import socket
import threading

def start_server(port, serverip):
    global serverThread, server
    server=socket.socket(socket.AF_INET, socket.SOCK_STREAM)
    server.bind((serverip, port))
    serverThread=threading.Thread(target=start)
    serverThread.start()
    
def start():
    global runn
    print("Server został uruchomiony i czeka na połączenie")
    server.listen()
    runn=True
    while runn:
        try:
            con, addres= server.accept()
            print(f"{addres} połączył się")
            users.append(con)
            addreses.append(addres)
            cn= threading.Thread(target=connection, args=(con, addres))
            cn.start()
        except:
            break

Sample of client code:

def connect_to_server(serverport, serverip):
    global client
    client=socket.socket(socket.AF_INET, socket.SOCK_STREAM)
    client.setsockopt(socket.SOL_SOCKET, socket.SO_REUSEADDR, 1)
    client.connect((serverip, serverport))

Solution

  • It was a problem of Windows defender. Hamachi has to be added to exceptions in public and private network.