Detect _write() failures and return false

If we're gonna return false on errors, might as well check both
_write() and _read().

Mostly this was done because php generates a Notice on each write / read
call on a disconnected socket. 2 Notices per call was kinda annoying.

This also incorporates pull #4 (a one line change) because it looks and performs better.