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()
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()
def disconn_client(self): try: socket.disconnectFromHost() except: pass if socket.state() == unconnected: print("Disconnected from server.") else: print("Connection to server still established.")