[vtkusers] Problem in "vtkSocketCommunicator" (Windows XP)
Markus Neff
markus.neff at brainlab.com
Tue May 20 08:10:43 EDT 2003
Dear VTK-Team,
on Windows XP, I have problems to send very large objects (in my case
of the class "vtkImageData") by calling
vtkSocketCommunicator::Send(...). The problem seems to be that the
respective OS "send()" call fails with the error code "WSAENOBUFS".
According to the documentation this indicates that "an operation on a
socket could not be performed because the system lacked sufficient
buffer space or because a queue was full."
I didn't try if other OS have comparable problems but it should not
hurt to hand the data to the network-layer in smaller
chunks. Therefore I suggest the patch below.
Best wishes,
Markus
============================== patch start =================================
--- vtkSocketCommunicator.1.40.cxx 2003-05-20 10:25:15.000000000 +0200
+++ vtkSocketCommunicator.cxx 2003-05-20 13:45:22.000000000 +0200
@@ -36,6 +36,8 @@ PURPOSE. See the above copyright notice
#define vtkCloseSocketMacro(sock) (close(sock))
#endif
+#define MAXSNDRCV 64 * 1024
+
vtkCxxRevisionMacro(vtkSocketCommunicator, "$Revision: 1.40 $");
vtkStandardNewMacro(vtkSocketCommunicator);
@@ -424,7 +426,9 @@ int vtkSocketCommunicator::SendInternal(
int total = 0;
do
{
- int n = send(socket, buffer+total, length-total, 0);
+ int remainder = length - total;
+ int sendnow = (remainder < MAXSNDRCV) ? remainder : MAXSNDRCV;
+ int n = send(socket, buffer+total, sendnow, 0);
if(n < 1)
{
return 0;
@@ -441,7 +445,9 @@ int vtkSocketCommunicator::ReceiveIntern
int total = 0;
do
{
- int n = recv(socket, buffer+total, length-total, 0);
+ int remainder = length - total;
+ int recvnow = (remainder < MAXSNDRCV) ? remainder : MAXSNDRCV;
+ int n = recv(socket, buffer+total, recvnow, 0);
if(n < 1)
{
return 0;
============================== patch end =================================
More information about the vtkusers
mailing list