Advertisement
khatta_cornetto

udpEchoClient.py

Jan 24th, 2025
63
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.31 KB | None | 0 0
  1. import socket
  2.  
  3. client_socket = socket.socket(socket.AF_INET, socket.SOCK_DGRAM)
  4.  
  5. server_address = ('127.0.0.1', 5)
  6. message = input("Enter a message: ").encode()
  7.  
  8. client_socket.sendto(message, server_address)
  9.  
  10. data, _ = client_socket.recvfrom(1024)
  11. print(f"Echo from server: {data.decode()}")
  12.  
  13. client_socket.close()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement