Fixed PHP-700: request/cursor mismatch

Discard of the socket when we have to return a failure, such as on timeout.

Although there is technically nothing wrong with the socket, our next
read to the server will return the data we are attempting to read right
now, hence resulting in completely random reply
Fixed CS in else if.
Merged pull request #375