summaryrefslogtreecommitdiff
path: root/Demo/sockets/broadcast.py
diff options
context:
space:
mode:
authorGuido van Rossum <guido@python.org>1992-05-19 13:52:02 +0000
committerGuido van Rossum <guido@python.org>1992-05-19 13:52:02 +0000
commitb83ec8f58de07a3c5ba53342b19670a96dcd254d (patch)
tree46d9c39dbc0f8c9f1cf001cff4e5cc1624861383 /Demo/sockets/broadcast.py
parentc99a4f900d1feb2f3be88949b766bb81ca0ccf08 (diff)
downloadcpython-git-b83ec8f58de07a3c5ba53342b19670a96dcd254d.tar.gz
Initial revision
Diffstat (limited to 'Demo/sockets/broadcast.py')
-rwxr-xr-xDemo/sockets/broadcast.py17
1 files changed, 17 insertions, 0 deletions
diff --git a/Demo/sockets/broadcast.py b/Demo/sockets/broadcast.py
new file mode 100755
index 0000000000..9ed900f0c6
--- /dev/null
+++ b/Demo/sockets/broadcast.py
@@ -0,0 +1,17 @@
+# Send UDP broadcast packets
+
+MYPORT = 50000
+
+import sys, time
+from socket import *
+
+s = socket(AF_INET, SOCK_DGRAM)
+s.bind('', 0)
+s.allowbroadcast(1)
+
+while 1:
+ data = `time.time()` + '\n'
+ s.sendto(data, ('<broadcast>', MYPORT))
+ time.sleep(2)
+
+