|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits
[2001-04-16 06:38 UTC] jmoore@php.net
[2001-05-13 19:21 UTC] jmoore@php.net
[2002-06-27 05:21 UTC] laurent at searchlores dot org
|
|||||||||||||||||||||||||||
Copyright © 2001-2025 The PHP GroupAll rights reserved. |
Last updated: Sat Nov 01 02:00:01 2025 UTC |
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