string[] splitString = client.Client.LocalEndPoint.ToString().Split(':');
IPEndPoint local = new IPEndPoint(IPAddress.Parse(splitString[0]),Int32.Parse(splitString[1]));
receiveUDPClient = new UdpClient(local);
IPEndPoint remote = new IPEndPoint(IPAddress.Any, 0);
int recAllLength = 0;
while (true)
{
try
{
byte[] receiveBytes= new Byte[1024 * 1024 * 2];
byte[] arr=new byte[1024*5];
arr = receiveUDPClient.Receive(ref remote);
Buffer.BlockCopy(arr, 0, receiveBytes, 0, arr.Length);
int recLength = receiveBytes.Length;
while (arr.ToString() != "over")
{
arr= receiveUDPClient.Receive(ref remote);
MessageBox.Show(arr.Length.ToString());
if (arr.ToString().Contains("over,"))
{
string[] splitstring = arr.ToString().Split(',');
recAllLength = Int32.Parse(splitstring[1]);
break;
}
MessageBox.Show(recLength.ToString() + "," + arr.Length.ToString());
Buffer.BlockCopy(arr, 0, receiveBytes,recLength,arr.Length );
recLength += arr.Length;
}
MessageBox.Show(recLength.ToString());
Now receiveBytes inside length of the value of 5 * 1024, but in fact may be less than the length of 5 * 1024, if the loop receiver, will not get the true value, and how do I get the true length of the receiver after the arr?
debug says recLength=1024*2*1024,but in fact it can be less than 5*1024,how can I get the real reclength?