- Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathudpsend.py
More file actions
Latest commit
26 lines (23 loc) · 506 Bytes
/
Copy pathudpsend.py
File metadata and controls
26 lines (23 loc) · 506 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
print("udp test")
importtime
importsocket
sock=socket.socket(socket.AF_INET, socket.SOCK_DGRAM)
sock.setblocking(False)
hostip=input('hostip:')
print("hostip:",hostip)
check=input('is ok? (y/n)')
ifcheck=='n':
exit()
count=0
whileTrue:
count+=1
time.sleep(0.5)
msg='test%d'%count
ifmsg=="exit" :
exit()
sock.sendto(msg.encode(), (hostip, 1234))
try:
data, addr=sock.recvfrom(1024)
print("reply:", data)
except:
pass