2zadanie/udp_client.py

10 lines
291 B
Python

import socket
client = socket.socket(socket.AF_INET, socket.SOCK_DGRAM)
message = input("Введите сообщение: ")
client.sendto(message.encode(), ('127.0.0.1', 10001))
data, addr = client.recvfrom(1024)
print(f"Ответ от сервера: {data.decode()}")
client.close()