[Group project!]
# # After at most $timeout milliseconds, return a string of at most $number_of_characters. # # Hide stuff inside some namespace. # proc read_with_timeout {channel number_of_characters timeout} {
# Preserve existing fileevent on $channel in order to restore it on return. # Define timeout handler. # Create character-at-a-time fileevent handler which accumulates result string. # Restore original fileevent.
}
# Variation, from entirely different direction: Expect's timeout.
# Also note that some channels (serial lines?) already admit timeout configuration. # Is it time for a TIP to propose that Tcl do this for all platforms/devices/...?