#include <sys/time.h>
#ifdef _WIN32
#include <winsock2.h>
-#define read(s,b,l) recv(s,(char*)b,l,0)
#define close closesocket
#undef errno
#define errno WSAGetLastError()
#include <os/winerrno.h>
#else
#include <sys/types.h>
+#include <sys/socket.h>
#include <unistd.h>
#endif
// blockCallback is set, it will be called (repeatedly) instead of blocking.
// If alternatively there is a timeout set and that timeout expires, it throws
// a TimedOut exception. Otherwise it returns the number of bytes read. It
-// never attempts to read() unless select() indicates that the fd is readable -
+// never attempts to recv() unless select() indicates that the fd is readable -
// this means it can be used on an fd which has been set non-blocking. It also
-// has to cope with the annoying possibility of both select() and read()
+// has to cope with the annoying possibility of both select() and recv()
// returning EINTR.
//
}
do {
- n = ::read(fd, buf, len);
+ n = ::recv(fd, (char*)buf, len, 0);
} while (n < 0 && errno == EINTR);
if (n < 0) throw SystemException("read",errno);
#include <errno.h>
#ifdef _WIN32
#include <winsock2.h>
-#define write(s,b,l) send(s,(const char*)b,l,0)
#undef errno
#define errno WSAGetLastError()
#include <os/winerrno.h>
// writeWithTimeout() writes up to the given length in bytes from the given
// buffer to the file descriptor. If there is a timeout set and that timeout
// expires, it throws a TimedOut exception. Otherwise it returns the number of
-// bytes written. It never attempts to write() unless select() indicates that
+// bytes written. It never attempts to send() unless select() indicates that
// the fd is writable - this means it can be used on an fd which has been set
// non-blocking. It also has to cope with the annoying possibility of both
-// select() and write() returning EINTR.
+// select() and send() returning EINTR.
//
int FdOutStream::writeWithTimeout(const void* data, int length, int timeoutms)