ǰλ: ҳ > >

tcl/tkο??*ṹvwait

ʱ:

.


.


?



vwait - һֱȴֱһ޸Ϊֹ



vwait varName


Tcl¼ѭTclһֱ¼ֱvarName޸ΪֹһvarName޸ˣvwait̷أvarNameһȫַΧҪôһȫֱҪôȫֿռ·


һЩvarName޸ĺvwait̷ܲأvarName¼ûɣôvwaitͲ̷ء磬һ¼varNameȻԼvwaitȥȴһͬıĻпҪʱܷء߶ջvwaitȴ¼ɣԲܷء


ʾ

¼ѭֱһЩ¼exit


vwait forever

һ׽ʱȴ5ӣر׽ּнű


# Initialise the state

after 5000 set state timeout

set server [socket -server accept 12345]

proc accept {args} {

global state connectionInfo

set state accepted

set connectionInfo $args

}

# Wait for something to happen

vwait state

# Clean up events that could have happened

close $server

after cancel set state timeout

# Do something based on how the vwait finished...

switch $state {

timeout {

puts "no connection on port 12345"

}

accepted {

puts "connection: $connectionInfo"

puts [lindex $connectionInfo 0] "Hello there!"

}

}



ӣ ʱ ܽ㱨 ׶ Сѧ ѧϰ