summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--main/network.c7
-rw-r--r--main/php_network.h6
2 files changed, 11 insertions, 2 deletions
diff --git a/main/network.c b/main/network.c
index 323d7f0673..046c5562c7 100644
--- a/main/network.c
+++ b/main/network.c
@@ -368,9 +368,12 @@ PHPAPI int php_connect_nonb_win32(SOCKET sockfd,
*/
int php_hostconnect(const char *host, unsigned short port, int socktype, int timeout)
{
- int n, repeatto, s, err;
+ int n, repeatto, s;
struct sockaddr **sal, **psal;
struct timeval timeoutval;
+#ifdef PHP_WIN32
+ int err;
+#endif
n = php_network_getaddresses(host, &sal);
@@ -765,7 +768,7 @@ printf("read_internal read %d/%d bytes\n", nr_bytes, sock->chunk_size);
memcpy(WRITEPTR(sock), buf, nr_bytes);
sock->writepos += nr_bytes;
nr_read = nr_bytes;
- } else if(nr_bytes == 0 || (nr_bytes < 0 && errno != EWOULDBLOCK)) {
+ } else if(nr_bytes == 0 || (nr_bytes < 0 && streams_socket_errno != EWOULDBLOCK)) {
sock->eof = 1;
}
diff --git a/main/php_network.h b/main/php_network.h
index 8e67f7ead8..404dc619de 100644
--- a/main/php_network.h
+++ b/main/php_network.h
@@ -43,6 +43,12 @@
# define ftruncate(a, b) chsize(a, b)
#endif /* defined(PHP_WIN32) */
+#ifdef PHP_WIN32
+#define streams_socket_errno WSAGetLastError()
+#else
+#define streams_socket_errno errno
+#endif
+
#ifdef HAVE_NETINET_IN_H
# include <netinet/in.h>
#endif