look at this code :
private bool SendPack(byte[] _Data)
{
try
{
NetworkStream clientStream = Servertcp.GetStream();
byte[] Pack = new byte[4 + _Data.Length];
byte[] len = BitConverter.GetBytes(_Data.Length);
len.CopyTo(Pack, 0);
buffer.CopyTo(Pack, 4);
clientStream.Write(Pack, 0, Pack.Length);
clientStream.Flush();
return true;
}
catch (Exception exp)
{
return false;
}
}
the function's behavior is strange! sometimes data is recei开发者_如何学JAVAved in client side, sometimes not. the function usually returns true, but in reality no data received, although client is connected to server. when i debuge the function i see that sometimes i lost the pointer after this line : clientStream.Write(Pack, 0, Pack.Length); i mean the pointer does not return to the lines after write...
Any Help would be appreciated.
精彩评论