> On May 14, 2:24 pm, Aman <ama
@gmail.com> wrote:
> > proc udpEvent {chan} {
> > set data [read $chan]
> > set peer [fconfigure $chan -peer]
> > puts "$peer [string length $data] '$data'"
> > if {[string match "QUIT*" $data]} {
> > close $chan
> > set ::forever 1
> > }
> > return
> > }
> > # Select a subnet and the port number.
> > set subnet 255.255.255.0
> > set port 7767
> > # Create a listening socket and configure for sending too.
> > set s [udp_open $port]
> > fconfigure $s -buffering none -blocking 0
> > fconfigure $s -broadcast 1 -remote [list $subnet $port]
> > fileevent $s readable [list udpEvent $s]
> > # Announce our presence and run
> > puts -nonewline $s "hello, world"
> > set forever 0
> > vwait ::forever
> > exit
> > Hi, Can someone please explain the execution sequence of this code..
> > It is meant to braodcast message.
> The fileevent and proc take care of incoming packets; guess you don't
> need help for this part.
> The writing part prepares for broadcast (fconfigure -broadcast 1 -
> remote ...), and the actual packet sending occurs in the puts
> (immediately because of -buffering none).
> Only this won't work because your broadcast address rather looks like
> a netmask ;-)
> -Alex
Thanks a ton Man..