Advertisement
johnpentyrch

serverUDP1

Jun 17th, 2020
305
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.32 KB | None | 0 0
  1. import socket
  2.  
  3. udp_server = socket.socket(socket.AF_INET, socket.SOCK_DGRAM)
  4. udp_server.bind(("0.0.0.0", 20001))
  5. #now get message from client
  6. data, client_address = udp_server.recvfrom(1024)
  7. #send same message back
  8. udp_server.sendto(data, client_address)
  9. #decode and print message
  10. message=data.decode()
  11. print(message)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement