Commit 77f2ce05 authored by Kenneth Moreland's avatar Kenneth Moreland
Browse files

BUG: Sometimes the Win32 recv function can return with the error WSAENOBUFS

but still be read on a subsequent call to recv.  Thus, on windows retry
several times on this error.  The solution is a little hack-y, but at worst
it should only cost a couple of seconds when reading on a socket that is
not working anyway.
parent 395047ce
......@@ -39,7 +39,7 @@
#define vtkCloseSocketMacro(sock) (close(sock))
vtkCxxRevisionMacro(vtkSocketCommunicator, "1.54");
vtkCxxRevisionMacro(vtkSocketCommunicator, "1.55");
......@@ -519,9 +519,22 @@ int vtkSocketCommunicator::ReceiveInternal(int socket, void* data, int length)
int total = 0;
#ifdef _WIN32
int trys = 0;
int n = recv(socket, buffer+total, length-total, 0);
if(n < 1)
#ifdef _WIN32
// On long messages, Windows recv sometimes fails with WSAENOBUFS, but
// will work if you try again.
int error = WSAGetLastError();
if ((error == WSAENOBUFS) && (trys++ < 1000))
return 0;
total += n;
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment