Exemple #1
0
def conn_to_server(ip_addr):
    socket.connectToHost(ip_addr, 1001)
    socket.waitForConnected(1000)

    if socket.state() == connected:
        print("Connection to host esteblished.")
    elif socket.state() == unconnected:
        print("Conncection to host failed.")
        return False
    else:
        print("TCP socket in state : ", socket.state())
        return socket.state()
Exemple #2
0
    def conn_client(self, ip):

        socket.connectToHost(ip, 1001)
        socket.waitForConnected(1000)

        if socket.state() == connected:
            print("Connection to server esteblished.")
            return True
        elif socket.state() == unconnected:
            print("Conncection to server failed.")
            return False
        else:
            print("TCP socket in state : ", socket.state())
            return socket.state()
Exemple #3
0
 def disconn_client(self):
     try:
         socket.disconnectFromHost()
     except:
         pass
     if socket.state() == unconnected:
         print("Disconnected from server.")
     else:
         print("Connection to server still established.")