"Better" impl of poll in timeout functions.

Added return of error response in poll calls and safer type coercion
when converting from (double) seconds to (int) ms.