Bug #8722 Updated: non blocking sockets reading doesn't work on WIN32

From: Date: Thu, 27 Jun 2002 09:21:13 +0000
Subject: Bug #8722 Updated: non blocking sockets reading doesn't work on WIN32
References: 1  Groups: php.bugs 
Request: Send a blank email to php-bugs+get-12217@lists.php.net to get a copy of this message
ID: 8722 Updated by: laurent@searchlores.org Reported By: christophe@winamp.com Status: Closed Bug Type: Sockets related Operating System: Any Windows OS PHP Version: 4.0.4pl1 New Comment: i am experiencing the same bug with php 4.2.1 under win98. Just tried latest CVS (4.3.0-dev, build today) and it's still there. applying christophe's patch to network.c (php_sockread_internal() has been moved from fsock.c to php_sock_stream_read_internal() in network.c) seems to solve the bug. Previous Comments: ------------------------------------------------------------------------ [2001-05-13 19:21:35] jmoore@php.net This appears to be fixed in latest CVS. (I cant reproduce this with or without your patch). Please try this with latest cvs and reopen if this is not the case. - James ------------------------------------------------------------------------ [2001-04-16 06:38:01] jmoore@php.net Ill test the patch and commit if it works well. It looks right to me. -James ------------------------------------------------------------------------ [2001-01-15 14:50:07] christophe@winamp.com i have the following script: $g_ssock=fsockopen($server,$port,$errno,$errstr,30); socket_set_blocking($g_ssock,0); while(!feof($g_ssock)) echo fgets($g_ssock,4096); if you uncomment the socket_set_blocking line it will work fine on win32, but with non blocking sockets, feof will always return true. by digging through the code, it appears that fsock.c uses the errno() function for determining any socket error as seen in function php_sockread_internal: } else if(nr_bytes == 0 || (nr_bytes < 0 && errno != EWOULDBLOCK)) { sock->eof = 1; } the problem is that win32 doesn't report socket errors with _errno() but with WSAGetLastError() so here is my fix: in fsock.c, line 46, replace: #ifdef PHP_WIN32 #include <winsock.h> #else with: #ifdef PHP_WIN32 #include <winsock.h> #undef errno #define errno (WSAGetLastError()) #else ------------------------------------------------------------------------ -- Edit this bug report at http://bugs.php.net/?id=8722&edit=1

« previous php.bugs (#12217) next »