diff --git a/Canguru/CanguruChat.py b/Canguru/CanguruChat.py index 97f762829d94bc01fd299e5b2e547a66ae800e2b..13124259c78011c7fa0539ba9eab32787369e8dd 100755 --- a/Canguru/CanguruChat.py +++ b/Canguru/CanguruChat.py @@ -31,9 +31,8 @@ import threading import sys import binascii -HOST = "127.0.0.1" # Endereco IP do Servidor SEND_PORT = 5000 # Porta que o Servidor envia -RECV_PORT = 5001 # Porta que o Servidor recebe +RECV_PORT = 5000 # Porta que o Servidor recebe MACHINE_ID = 1 class Protocol(): @@ -123,18 +122,17 @@ def client (): def server (): udp = socket.socket(socket.AF_INET, socket.SOCK_DGRAM) - orig = (HOST, RECV_PORT) + orig = ('', RECV_PORT) udp.bind(orig) protocolDescompactMessage = Protocol() while True: msg, cliente = udp.recvfrom(1024) protocolDescompactMessage.setDesempacota(msg) - if protocolDescompactMessage.destiny == MACHINE_ID: - if protocolDescompactMessage.crc == protocolDescompactMessage.getCRC32(): - print msg - print '\n' + protocolDescompactMessage.origin + ' Escreveu: ' + protocolDescompactMessage.msg - else: - print 'ERRO, A MENSAGEM FOI RECIBIDA ERRADA' + if protocolDescompactMessage.crc == protocolDescompactMessage.getCRC32(): + print msg + print '\n' + protocolDescompactMessage.origin + ' Escreveu: ' + protocolDescompactMessage.msg + else: + print 'ERRO, A MENSAGEM FOI RECIBIDA ERRADA' udp.close() #------------------MAIN-----------------# @@ -143,8 +141,9 @@ if len(sys.argv) > 1: AUX = RECV_PORT RECV_PORT = SEND_PORT SEND_PORT = AUX - +print "Ip da proxima maquina" +HOST = raw_input() threadServer = threading.Thread(target=server) threadClient = threading.Thread(target=client) threadServer.start() -threadClient.start() \ No newline at end of file +threadClient.start()