Posted to tcl by Ro at Mon Mar 05 15:18:05 GMT 2007view pretty


console show

set dir [file dirname [info nameofexe]]

lappend auto_path [file join $dir lib]


proc file_get {fn} {set f [open $fn r] ; set c [read $f] ; close $f ; return $c}

proc get_1000ip_list {} {
  return [split [file_get [file join $::dir 1000ip.txt]] \n]
}



proc socketzoom {count IP s} {

  fileevent $s writable {}


  set emsg [fconfigure $s -error]

  close $s

  if {![string equal $emsg ""]} {
    puts "$count : $IP ERROR $s : $emsg" ; update
  } else {
    puts "$count : $IP conn! $s" ; update
  }


}



label .fired -font {{Lucida Console} 16}
pack .fired -fill x -expand 1


set count 0
foreach IP [get_1000ip_list] {

  set s [socket -async $IP 80]
  fileevent $s writable [list socketzoom $count $IP $s]

  .fired conf -text "Fired Off $count"
  
  update
  incr count
}


Comments

Posted by davygrvy at Mon Mar 05 19:08:43 GMT 2007 [text] [code]

remove the [update] calls from [socketzoom]. Calling update from a fileevent is bad and can eat-up your stack space. The event loop is already servicing this proc, so entering the event loop again increases the stack without unwinding.