]> granicus.if.org Git - php/commitdiff
Fix feof() on win32
authorJason Greene <jason@php.net>
Fri, 19 Jul 2002 20:34:35 +0000 (20:34 +0000)
committerJason Greene <jason@php.net>
Fri, 19 Jul 2002 20:34:35 +0000 (20:34 +0000)
Bug #18436

main/network.c
main/php_network.h

index 323d7f06737db99e53aa8d9c349812980243cf00..046c5562c7bef019b487bfc798d517eb526bd36b 100644 (file)
@@ -368,9 +368,12 @@ PHPAPI int php_connect_nonb_win32(SOCKET sockfd,
  */
 int php_hostconnect(const char *host, unsigned short port, int socktype, int timeout)
 {      
-       int n, repeatto, s, err;
+       int n, repeatto, s;
        struct sockaddr **sal, **psal;
        struct timeval timeoutval;
+#ifdef PHP_WIN32
+       int err;
+#endif
        
        n = php_network_getaddresses(host, &sal);
 
@@ -765,7 +768,7 @@ printf("read_internal read %d/%d bytes\n", nr_bytes, sock->chunk_size);
                memcpy(WRITEPTR(sock), buf, nr_bytes);
                sock->writepos += nr_bytes;
                nr_read = nr_bytes;
-       } else if(nr_bytes == 0 || (nr_bytes < 0 && errno != EWOULDBLOCK)) {
+       } else if(nr_bytes == 0 || (nr_bytes < 0 && streams_socket_errno != EWOULDBLOCK)) {
                sock->eof = 1;
        }
 
index 8e67f7ead848fd7e506a3c6ea2ef8482b21ac814..404dc619de648a84e46ac4a8f4dfe309469802ec 100644 (file)
 #      define ftruncate(a, b) chsize(a, b)
 #endif /* defined(PHP_WIN32) */
 
+#ifdef PHP_WIN32
+#define streams_socket_errno WSAGetLastError()
+#else
+#define streams_socket_errno errno
+#endif
+
 #ifdef HAVE_NETINET_IN_H
 # include <netinet/in.h>
 #endif