*/
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);
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;
}
# 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