avoid TCP Zero Window/ TCP Window Full on the receiver side?

7
  down vote favorite 
1

I have a small application which sends files over the network to an agent located on a Windows OS.

When this application runs on Windows, everything works fine, the communication is OK and the files are all copied successfully.

But, when this application runs on Linux (RedHat 5.3, the receiver is still Windows) - I see in Wireshark network trace messages of TCP Zero Window and TCP Window Full to appear on each 1-2 seconds. The agent then closes the connection after some minutes.

The Windows - Linux code is almost the same, and pretty simple. The only non-trivial operation is setsockopt with SO_SNDBUF and value of 0xFFFF. Removing this code didn't help.

Can someone please help me with this issue?

EDIT: adding the sending code - it looks that it handles properly partial writes

int totalSent=0;
while(totalSent != dataLen)
{
int bytesSent 
=::send(_socket,(char*)(data+totalSent), dataLen-totalSent,0);

if(bytesSent ==0){
return totalSent;
}
elseif(bytesSent == SOCKET_ERROR){
#ifdef __WIN32
int errcode =WSAGetLastError();
if( errcode==WSAEWOULDBLOCK ){
#else
if((errno == EWOULDBLOCK)||(errno == EAGAIN)){
#endif
}
else{
if(!totalSent ){
                    totalSent 
= SOCKET_ERROR;
}
break;
}
}
else{
            totalSent
+=bytesSent;
}
}
}

 

// blocking send, timeout is handled by caller reading errno on short send
int doSend(int s,constvoid*buf,size_t dataLen){
int totalSent=0;

while(totalSent != dataLen)
{
int bytesSent 
= send(s,((char*)data)+totalSent, dataLen-totalSent, MSG_NOSIGNAL);

if( bytesSent <0&& errno != EINTR )
break;

        totalSent 
+= bytesSent;
}
return totalSent;
}

摘自:http://stackoverflow.com/questions/3433520/what-can-i-do-to-avoid-tcp-zero-window-tcp-window-full-on-the-receiver-side

你可能感兴趣的:(windows,NetWork,seconds,Everything,appear)