Created
January 19, 2021 04:52
-
-
Save ashelly/67e133da5d9accdb3568a513a631d678 to your computer and use it in GitHub Desktop.
Python UDP Client
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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