def run(self): #The user enter the server ip address. global root root = Tk() lab = Label(root, text="What server do you want to connect?") lab.pack(side=TOP) global ent ent = Entry(root) ent.pack(fill=X) ent.focus() ent.bind('<Return>', self.fetch) btn = Button(root, text="OK", command = self.fetch) btn.pack(side=BOTTOM) root.mainloop() self.cryptor = None #in charge of encrypting and decrypting serverPort = 24766 global sockobj sockobj = socket(AF_INET, SOCK_STREAM) sockobj.connect((self.serverHost, serverPort)) global gui gui = WBGui(server=self) gui.printCon('Connected to server: '+self.serverHost+'\n') thread.start_new_thread(self.listen, (sockobj, self.serverHost, )) gui.mainloop() sockobj.close()
def run(self): myHost = '' myPort = 24766 self.cryptor = None #in charge of encrypting and decrypting sockobj = socket(AF_INET, SOCK_STREAM) sockobj.bind((myHost, myPort)) sockobj.listen(5) global connection global address connection, address = sockobj.accept() global gui gui = WBGui(server=self) gui.printCon('Server connected by ' + str(address)+'\n') thread.start_new_thread(self.recvData, ()) gui.mainloop()