}
if (retval == -1) {
- PHP_SOCKET_ERROR(php_sock, "unable to read from socket", errno);
+ /* if the socket is in non-blocking mode and there's no data to read,
+ don't output any error, as this is a normal situation, and not an error */
+ if (errno == EAGAIN
+#ifdef EWOULDBLOCK
+ || errno == EWOULDBLOCK
+#endif
+ ) {
+ php_sock->error = errno;
+ SOCKETS_G(last_error) = errno;
+ } else {
+ PHP_SOCKET_ERROR(php_sock, "unable to read from socket", errno);
+ }
+
efree(tmpbuf);
RETURN_FALSE;
}