class Connect(object): #发送数据 def DealOut(s): global nick, outString while True: outString = raw_input() outString = nick + ': ' + outString s.send(outString)
#接收数据 def DealIn(s): global inString while True: try: inString = s.recv(1024) if not inString: break if outString != inString: print inString if inString == str(25352): ServerPool.get_instance().del_server(25352) except: break
def defcon(): inString = '' outString = '' nick = '' ip = Config.MASTER_SERVER_IP port = Config.MASTER_SERVER_PORT nick = Config.SERVER_NAME sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM) sock.bind(("0.0.0.0", Config.CLIENT_PORT)) sock.connect((ip, port)) sock.send(nick)