File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 66# mcast (receivers)
77
88MYPORT = 8123
9- MYGROUP_BYTES = 225 , 0 , 0 , 250
9+ MYGROUP = ' 225.0.0. 250'
1010
1111import sys
1212import time
1313import struct
14+ import regsub
1415from socket import *
1516from SOCKET import *
16- from IN import *
17+ from IN import * # Local module, SGI specific!!!
1718
1819sender = sys .argv [1 :]
1920
2425 s .setsockopt (SOL_SOCKET , SO_BROADCAST , 1 )
2526 mygroup = '<broadcast>'
2627 else :
27- # Ugly: construct decimal IP address string from MYGROUP_BYTES
28- mygroup = ''
29- for byte in MYGROUP_BYTES : mygroup = mygroup + '.' + `byte`
30- mygroup = mygroup [1 :]
28+ mygroup = MYGROUP
3129 ttl = struct .pack ('b' , 1 ) # Time-to-live
3230 s .setsockopt (IPPROTO_IP , IP_MULTICAST_TTL , ttl )
3331 while 1 :
4240 # Allow multiple copies of this program on one machine
4341 s .setsockopt (SOL_SOCKET , SO_REUSEPORT , 1 ) # (Not strictly needed)
4442
45- # Ugly: construct binary group address from MYGROUP_BYTES
43+ # Ugly: construct binary group address from MYGROUP converted to bytes
44+ bytes = eval (regsub .gsub ('\.' , ',' , MYGROUP ))
4645 grpaddr = 0
47- for byte in MYGROUP_BYTES : grpaddr = (grpaddr << 8 ) | byte
46+ for byte in bytes : grpaddr = (grpaddr << 8 ) | byte
4847
4948 # Construct struct mreq from grpaddr and ifaddr
5049 ifaddr = INADDR_ANY
You can’t perform that action at this time.
0 commit comments