-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathsend.py
More file actions
31 lines (26 loc) · 765 Bytes
/
send.py
File metadata and controls
31 lines (26 loc) · 765 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
27
28
29
30
31
#!/usr/bin/env python
# -*- coding: utf-8 -*-
import socket
import sys
import time
# print sys.argv
if len(sys.argv) == 2:
UDP_IP = sys.argv[1]
else:
UDP_IP = '255.255.255.255' #"192.168.1.182"
UDP_PORT = 60407
# UDP_PORT = 61070
# UDP_PORT = 60107 #60411
print("UDP target IP:", UDP_IP)
print("UDP target port:", UDP_PORT)
sock = socket.socket(socket.AF_INET, # Internet
socket.SOCK_DGRAM)#,
# socket.IPPROTO_UDP) # UDP
sock.setsockopt(socket.SOL_SOCKET, socket.SO_BROADCAST, 1)
for i in range(100):
# sock.sendto("4", (UDP_IP, UDP_PORT))
msg = input("Command: ")
sock.sendto(msg.encode(), (UDP_IP, UDP_PORT))
# sock.sendto(str(msg), (UDP_IP, UDP_PORT))
print(i, time.time())
time.sleep(0.1)