php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Return to Bug #50953
Patch connect_fix_win32 revision 2010-09-07 08:26 UTC by cataphract@php.net

Patch connect_fix_win32 for Sockets related Bug #50953

Patch version 2010-09-07 08:26 UTC

Return to Bug #50953 | Download this patch
Patch Revisions:

Developer: cataphract@php.net

Index: network.c
===================================================================
--- network.c	(revision 303115)
+++ network.c	(working copy)
@@ -338,7 +338,18 @@
 		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) {
+#endif
 		error = PHP_TIMEOUT_ERROR_VALUE;
 	}
 
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Thu Nov 21 17:01:32 2024 UTC