~malept/ubuntu/lucid/python2.6/dev-dependency-fix

« back to all changes in this revision

Viewing changes to Demo/sockets/broadcast.py

  • Committer: Bazaar Package Importer
  • Author(s): Matthias Klose
  • Date: 2009-02-13 12:51:00 UTC
  • Revision ID: james.westby@ubuntu.com-20090213125100-uufgcb9yeqzujpqw
Tags: upstream-2.6.1
ImportĀ upstreamĀ versionĀ 2.6.1

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
# Send UDP broadcast packets
 
2
 
 
3
MYPORT = 50000
 
4
 
 
5
import sys, time
 
6
from socket import *
 
7
 
 
8
s = socket(AF_INET, SOCK_DGRAM)
 
9
s.bind(('', 0))
 
10
s.setsockopt(SOL_SOCKET, SO_BROADCAST, 1)
 
11
 
 
12
while 1:
 
13
    data = repr(time.time()) + '\n'
 
14
    s.sendto(data, ('<broadcast>', MYPORT))
 
15
    time.sleep(2)