supports KeyboardInterrupt
use select.select for socket