select I/O

add two error handler fucntions. And use select function set 5s for wait, if overtime, return directly.