我正在尝试重用线程并UdpClient
在同一端口上发送和接收,但是当我调用方法时..
private void RecivedCallback(IAsyncResult ar)
{
try
{
if (ar == cuurentsynResult)
{
UdpClient c = (UdpClient)((UdpState)(ar.AsyncState)).c;
IPEndPoint e = (IPEndPoint)((UdpState)(ar.AsyncState)).e;
Byte[] buffer = c.EndReceive(ar, ref e);
if (buffer.Length > 0)
System.Console.WriteLine(System.Text.Encoding.UTF8.GetString(buffer));
UdpState s = new UdpState(e, c);
cuurentsynResult = udpclient.BeginReceive(new AsyncCallback(RecivedCallback), s);
}
}
catch (Exception ex)
{
string str = ex.Message;
}
}
我面临的例外是..远程主机强行关闭了现有连接,所以我该如何解决这个问题。请发送您的意见或答案
索努·兰詹