You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
var recvall2:Function=function( socket:int, bytes:ByteArray, len:int=8192, flags:int=0 ):int
{
var total:uint = 0; // how many bytes we receivedvar n:int;
var b:ByteArray = new ByteArray();
var run:Boolean = true;
while( run )
{
b.clear();
n = recv( socket, b, len, flags );if( n ==-1 ) { run =false;break; }
bytes.writeBytes( b );total+= n;if( n ==0 ) { run =false;break; }
}
b.clear();
if( n < 0 )
{
return-1;//failure
}
return total; // number of bytes actually received
}
the loop need to check on "bytes recv zero"
and not "bytes recv smaller than buffer"
eg. //if( n < len ) { run = false; break; } // bad if( n == 0 ) { run = false; break; } // good
if you trace( "n = " + n );
on getting an HTTML page you get something like
n = 1448
n = 1448
n = 2896
n = 1448
n = 1448
n = 1448
n = 2896
n = 1448
n = 1448
n = 1448
n = 1448
n = 1448
n = 1448
n = 2896
n = 1534
n = 0
even if the buffer is max=8192 bytes
depending on network settings and other MTU window
we can recevie s,aller chunk than the buffer
which is what create the bug
the real indicator of "all is received" is when we receive zero bytes
The text was updated successfully, but these errors were encountered:
https://code.google.com/p/redtamarin/issues/detail?id=104
in
the utility function recvall() has a bug
here the fix
the loop need to check on "bytes recv zero"
and not "bytes recv smaller than buffer"
eg.
//if( n < len ) { run = false; break; } // bad
if( n == 0 ) { run = false; break; } // good
if you
trace( "n = " + n );
on getting an HTTML page you get something like
even if the buffer is max=8192 bytes
depending on network settings and other MTU window
we can recevie s,aller chunk than the buffer
which is what create the bug
the real indicator of "all is received" is when we receive zero bytes
The text was updated successfully, but these errors were encountered: