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.
16 lines
435 B
16 lines
435 B
import socket
|
|
|
|
HOST = ''
|
|
PORT = 2000
|
|
|
|
with socket.socket(socket.AF_INET, socket.SOCK_DGRAM) as s:
|
|
s_addr = (HOST, PORT)
|
|
s.bind(s_addr)
|
|
while True:
|
|
datos, addr = s.recvfrom(1024)
|
|
print("recibidos {} bytes de {}".format(len(datos), addr))
|
|
print(datos)
|
|
|
|
if datos:
|
|
sent = s.sendto(b"Saludos desde el servidor UDP", addr)
|
|
print('enviados {} bytes a {}'.format(sent, addr)) |