#include <sys/time.h>
#ifdef _WIN32
#include <winsock2.h>
+#define errorNumber WSAGetLastError()
#define close closesocket
-#undef errno
-#define errno WSAGetLastError()
#include <os/winerrno.h>
#else
#include <sys/types.h>
#include <sys/socket.h>
#include <unistd.h>
+#define errorNumber errno
#endif
/* Old systems have select() in sys/time.h */
FD_ZERO(&fds);
FD_SET(fd, &fds);
n = select(fd+1, &fds, 0, 0, &tv);
- } while (n < 0 && errno == EINTR);
+ } while (n < 0 && errorNumber == EINTR);
if (n < 0)
- throw SystemException("select",errno);
+ throw SystemException("select", errorNumber);
if (n == 0)
return 0;
do {
n = ::recv(fd, (char*)buf, len, 0);
- } while (n < 0 && errno == EINTR);
+ } while (n < 0 && errorNumber == EINTR);
if (n < 0)
- throw SystemException("read",errno);
+ throw SystemException("read", errorNumber);
if (n == 0)
throw EndOfStream();
#include <errno.h>
#ifdef _WIN32
#include <winsock2.h>
-#undef errno
-#define errno WSAGetLastError()
+#define errorNumber WSAGetLastError()
#include <os/winerrno.h>
#else
#include <sys/types.h>
#include <sys/socket.h>
#include <netinet/in.h>
#include <netinet/tcp.h>
+#define errorNumber errno
#endif
/* Old systems have select() in sys/time.h */
FD_ZERO(&fds);
FD_SET(fd, &fds);
n = select(fd+1, 0, &fds, 0, &tv);
- } while (n < 0 && errno == EINTR);
+ } while (n < 0 && errorNumber == EINTR);
if (n < 0)
- throw SystemException("select", errno);
+ throw SystemException("select", errorNumber);
if (n == 0)
return 0;
#else
n = ::send(fd, (const char*)data, length, MSG_DONTWAIT);
#endif
- } while (n < 0 && (errno == EINTR));
+ } while (n < 0 && (errorNumber == EINTR));
if (n < 0)
- throw SystemException("write", errno);
+ throw SystemException("write", errorNumber);
gettimeofday(&lastWrite, NULL);