C#中如何计算UDP的丢包率?
发布网友
发布时间:2022-04-24 04:29
我来回答
共1个回答
热心网友
时间:2023-10-28 03:38
string sResult=string.Empty;
bool bResult=false;
byte[] buf=new byte[2048];
try
{
IPEndPoint sender=new IPEndPoint(IPAddress.Any, 2425);
EndPoint tempRemoteEP=(EndPoint)sender;
IAsyncResult ias=socket.BeginReceiveFrom(buf, 0, 2048, SocketFlags.None, ref tempRemoteEP, null, null);
bResult = ias.AsyncWaitHandle.WaitOne(500, false);
if (bResult)
{
socket.EndReceiveFrom(ias, ref tempRemoteEP);
}
}
catch(Exception ex)
{
}
热心网友
时间:2023-10-28 03:38
string sResult=string.Empty;
bool bResult=false;
byte[] buf=new byte[2048];
try
{
IPEndPoint sender=new IPEndPoint(IPAddress.Any, 2425);
EndPoint tempRemoteEP=(EndPoint)sender;
IAsyncResult ias=socket.BeginReceiveFrom(buf, 0, 2048, SocketFlags.None, ref tempRemoteEP, null, null);
bResult = ias.AsyncWaitHandle.WaitOne(500, false);
if (bResult)
{
socket.EndReceiveFrom(ias, ref tempRemoteEP);
}
}
catch(Exception ex)
{
}
热心网友
时间:2023-10-28 03:38
string sResult=string.Empty;
bool bResult=false;
byte[] buf=new byte[2048];
try
{
IPEndPoint sender=new IPEndPoint(IPAddress.Any, 2425);
EndPoint tempRemoteEP=(EndPoint)sender;
IAsyncResult ias=socket.BeginReceiveFrom(buf, 0, 2048, SocketFlags.None, ref tempRemoteEP, null, null);
bResult = ias.AsyncWaitHandle.WaitOne(500, false);
if (bResult)
{
socket.EndReceiveFrom(ias, ref tempRemoteEP);
}
}
catch(Exception ex)
{
}