Hi All,
a small question about some code we implemented:
if ( rxSize > 0 )
{
byte[] buf = new byte[rxSize] ;
int total = 0 ;
int offset = 0 ;
int counterRead = 0 ;
int counterSleep = 0 ;
// put incoming bytes onto the input stream
while ( ( !m_Terminate )
&& ( rxSize > 0 ) )
{
// stream = new NetworkStream( socket, false );
if ( stream.DataAvailable == false )
{
counterSleep++;
System.Threading.Thread.Sleep( 50 ); // it was normally 100 but 50 went better ( 10 was to low )
}
else
{
counterRead++;
tmrPong.Change( 10000, Timeout.Infinite ); //pong messages (unimportant for this issue)
total = stream.Read( buf, offset, rxSize );
rxSize -= total;
offset += total;
}
}
// put message on queue
if ( rxSize == 0 )
{
Logger.TheLogger.Info("Msg sub counters: read - " + counterRead.ToString() + ", sleep - " + counterSleep.ToString() );
Logger.TheLogger.Info( "msg rx:", buf, buf.Length );
m_In.Enqueue( buf );
}
}
(sorry for the pasting, is there a better way to show you the code )
Now we see that the counterSleep at the end (for +/- 2488 bytes) is 7 to 10. Which means we sleep for +/- 350 - 500 milliseconds.
Is this normal ![]()
If so, does it mean that the send is slow Can i boost the read
Any help is welcome...
THX

NetworkStream.Read performance
A_Bomb
parthasarathy
Valdair,
it's not that i don't believe you, but where can i find those details of networkstream having for example a incoming buffersize of 8K.
I must be able to prove, that the networkstream read that i'm using is not the problem. But that it is indeed, the sending device, which is to slow.
( I set it on full duplex 100, but my network card stops working, i assume it does not support the 100 :), full duplex 10 works, but no difference there)
Thx already for the help, ...
grtz,
ak8888
Thx !
i had ethereal already installed :)
i found the issue: the otherside was idd the problem.
G.T.
it's right there in the help files
http://msdn.microsoft.com/library/default.asp url=/library/en-us/cpref/html/frlrfsystemnetsocketstcpclientclassreceivebuffersizetopic.asp
if your computer is plugged into hub and not a switch then you can only set your card to 10 half duplex, I would also suggest downloading Etheral which easily allows you to see the packets going between two computers. Remember that in network programming the error can be in the server, the client, or anywhere in between the two. This stuff is rarely easy.