Advertisement
johnpentyrch

clientUDP1

Jun 17th, 2020
296
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.41 KB | None | 0 0
  1. import socket
  2. client_socket = socket.socket(socket.AF_INET, socket.SOCK_DGRAM)
  3. client_socket.connect(("127.0.0.1",20001))
  4. print("Connected")
  5.  
  6. #Send a message  to the server
  7. message="Have a Great Day"
  8. data=message.encode()
  9. client_socket.send(data)
  10. #readmessage back from server
  11. data=client_socket.recv(1024)
  12. #now decode and print it
  13. message=data.decode()
  14. print(message)
  15. #close socket
  16. client_socket.close()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement