Skip to content
Snippets Groups Projects
Commit 605d3c38 authored by Fernando Erd's avatar Fernando Erd :ok_hand:
Browse files

send hostname to server

parent a3c28f7d
No related branches found
No related tags found
No related merge requests found
...@@ -20,19 +20,22 @@ def client (): ...@@ -20,19 +20,22 @@ def client ():
dest = (HOST, PORT) dest = (HOST, PORT)
print 'Para sair digite exit\n' print 'Para sair digite exit\n'
print 'Escreva a mensagem' print 'Mensagem:'
msg = raw_input() msg = raw_input()
if msg != 'exit': if msg != 'exit':
print 'Qual a Prioridade?' print 'Prioridade:'
priority = raw_input () priority = raw_input ()
hostname = socket.gethostname() # Pega o hostname
while msg <> 'exit': while msg <> 'exit':
udp.sendto (msg, dest) udp.sendto (hostname, dest) # Envia Hostname
print 'Escreva a mensagem' udp.sendto (msg, dest) #Envia Mensagem
print 'Mensagem:'
msg = raw_input() msg = raw_input()
if msg != 'exit': if msg != 'exit':
print 'Qual a Prioridade?' print 'Prioridade:'
priority = raw_input () priority = raw_input ()
hostname = socket.gethostname()
t.stop () t.stop ()
udp.close() udp.close()
......
...@@ -5,6 +5,7 @@ udp = socket.socket(socket.AF_INET, socket.SOCK_DGRAM) ...@@ -5,6 +5,7 @@ udp = socket.socket(socket.AF_INET, socket.SOCK_DGRAM)
orig = (HOST, PORT) orig = (HOST, PORT)
udp.bind(orig) udp.bind(orig)
while True: while True:
msg, cliente = udp.recvfrom(1024) hostname, cliente_ip= udp.recvfrom (1024)
print cliente, msg msg,client_ip = udp.recvfrom(1024)
print hostname, ':', msg
udp.close() udp.close()
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment