summaryrefslogtreecommitdiff
path: root/main/network.c
diff options
context:
space:
mode:
authorPierre Joye <pajoye@php.net>2010-09-07 09:47:36 +0000
committerPierre Joye <pajoye@php.net>2010-09-07 09:47:36 +0000
commit7ce4f4955dbb82d41210a932db844041953bdd2e (patch)
treedd115c5a0a34b0030e194bface18c346641fa97e /main/network.c
parent2110655d4d7fe692e08d77ce407633c10b2dc624 (diff)
downloadphp-git-7ce4f4955dbb82d41210a932db844041953bdd2e.tar.gz
- fix bug #50953, socket will not connect to IPv4 address when the host has both ipv4 and ipv6 addresses
Diffstat (limited to 'main/network.c')
-rw-r--r--main/network.c12
1 files changed, 11 insertions, 1 deletions
diff --git a/main/network.c b/main/network.c
index 99d4ed8437..36181da55d 100644
--- a/main/network.c
+++ b/main/network.c
@@ -337,9 +337,19 @@ PHPAPI int php_network_connect_socket(php_socket_t sockfd,
if (n == 0) {
goto ok;
}
-
+# ifdef PHP_WIN32
+ /* The documentation for connect() says in case of non-blocking connections
+ * the select function reports success in the writefds set and failure in
+ * the exceptfds set. Indeed, using PHP_POLLREADABLE results in select
+ * failing only due to the timeout and not immediately as would be
+ * exepected when a connection is actively refused. This way,
+ * php_pollfd_for will return a mask with POLLOUT if the connection
+ * is successful and with POLLPRI otherwise. */
+ if ((n = php_pollfd_for(sockfd, POLLOUT|POLLPRI, timeout)) == 0) {
+#else
if ((n = php_pollfd_for(sockfd, PHP_POLLREADABLE|POLLOUT, timeout)) == 0) {
error = PHP_TIMEOUT_ERROR_VALUE;
+#endif
}
if (n > 0) {