From:             [EMAIL PROTECTED]
Operating system: Any Windows OS
PHP version:      4.0.4pl1
PHP Bug Type:     Sockets related
Bug description:  non blocking sockets reading doesn't work on WIN32

i have the following script:

    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>


#ifdef PHP_WIN32
#include <winsock.h>
#undef errno
#define errno (WSAGetLastError())

Edit Bug report at:

PHP Development Mailing List <>
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]

Reply via email to