Skip to content

Instantly share code, notes, and snippets.

@ashelly
Created January 19, 2021 04:52
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ashelly/67e133da5d9accdb3568a513a631d678 to your computer and use it in GitHub Desktop.
Save ashelly/67e133da5d9accdb3568a513a631d678 to your computer and use it in GitHub Desktop.
Python UDP Client
import socket
fd = socket.socket(socket.AF_INET, socket.SOCK_DGRAM )
fd.settimeout(1)
udp_ip = '10.82.2.254'
udp_port = 4001
while(True):
message = input("> ")+"\r"
fd.sendto(message.encode(), (udp_ip, udp_port))
while(True):
try:
reply = fd.recvfrom(1000)
print(reply[0])
except socket.timeout:
break
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment