You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
19 lines
491 B
19 lines
491 B
10 months ago
|
import socket
|
||
|
|
||
|
HOST = '192.168.50.106'
|
||
|
PORT = 2000
|
||
|
|
||
|
with socket.socket(socket.AF_INET, socket.SOCK_DGRAM) as s:
|
||
|
s_addr = (HOST, PORT)
|
||
|
server_address = (s_addr)
|
||
|
cadena = input("Por favor, introduce una cadena: ")
|
||
|
message = bytes(cadena, 'utf-8')
|
||
|
|
||
|
# enviar
|
||
|
print('Enviando {!r}'.format(message))
|
||
|
sent = s.sendto(message, server_address)
|
||
|
|
||
|
# recibir
|
||
|
print('Esperando por la respuesta')
|
||
|
data, server = s.recvfrom(1024) #línea bloqueante
|
||
|
print('recibidos {!r}'.format(data))
|