From: Pierre Ossman Date: Wed, 8 Nov 2017 14:59:42 +0000 (+0100) Subject: Fully standardise on send()/recv() X-Git-Tag: v1.8.90~82 X-Git-Url: https://source.dussan.org/?a=commitdiff_plain;h=e5cdadd6deca3c0d2af6bc0ab2b60a11f5c6ad4a;p=tigervnc.git Fully standardise on send()/recv() We already assume sockets here since we use select(). --- diff --git a/common/rdr/FdInStream.cxx b/common/rdr/FdInStream.cxx index a8b30857..011ebf41 100644 --- a/common/rdr/FdInStream.cxx +++ b/common/rdr/FdInStream.cxx @@ -26,13 +26,13 @@ #include #ifdef _WIN32 #include -#define read(s,b,l) recv(s,(char*)b,l,0) #define close closesocket #undef errno #define errno WSAGetLastError() #include #else #include +#include #include #endif @@ -165,9 +165,9 @@ int FdInStream::overrun(int itemSize, int nItems, bool wait) // 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. // @@ -207,7 +207,7 @@ int FdInStream::readWithTimeoutOrCallback(void* buf, int len, bool wait) } 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); diff --git a/common/rdr/FdOutStream.cxx b/common/rdr/FdOutStream.cxx index 8fe9df94..cf857f85 100644 --- a/common/rdr/FdOutStream.cxx +++ b/common/rdr/FdOutStream.cxx @@ -27,7 +27,6 @@ #include #ifdef _WIN32 #include -#define write(s,b,l) send(s,(const char*)b,l,0) #undef errno #define errno WSAGetLastError() #include @@ -161,10 +160,10 @@ int FdOutStream::overrun(int itemSize, int nItems) // 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)