Example: Event-Driven vs Thread I/O
I/O bound apps are sometimes easier with threads:
if {[incr count -1] == 0} {
puts $sock "GET /index.html\r\n"
fileevent $sock readable "my.read $sock"
foreach host { host1 host2 host3 host4} {
set sock [socket -async $host 80]
fconfigure $sock -blocking off
fileevent $sock writable "my.write $sock"
set sock [socket $host 80]
puts $sock "GET /index.html\r\n"
foreach host {host1 host2 host3 host4} {
lappend tids [ns_thread begin ”my.thread $host"]