What's done with the Send method of UdpClient?

I'm writing something with UdpClient.Here I got some problem.I am confusing about the Send method,what will be done with the UdpClient when I Send smothing to an unavailable hostend using the Send method.
Here is some of my code.
I just use a udpclient to send something to the server and then wait for the server's apply.

IPEndPoint server=new IPEndPoint(IPAddress.Parse("60.25.34.200"), 5100);
IPEndPoint local= new IPEndPoint(Dns.Resolve(Dns.GetHostName()).AddressList[0], 5400);
udpClient = new UdpClient(local);
IPEndPoint remote = new IPEndPoint(IPAddress.Any, 0);
byte[] bytes = System.Text.Encoding.ASCII.GetBytes("something");
udpClient = new UdpClient(local);
//Send something to the server
int count=_udpClient.Send(bytes, bytes.Length, server);
//this will catch a problem when the server is unavailable.
bytes = _udpClient.Receive(ref remote);

when the server IpEndPoint is available,the program will be ok,it blocked in the Receive method waiting for the replay.
But when the server IpEndPoint is unavailable,the problem comes I will receive a SocketException in the Receive Method.
I just want to know wheather the Send method has send the data to server.
Any reply will be helpful.
Thanks in advance!


Answer this question

What's done with the Send method of UdpClient?

  • sroughley

    Thanks for you reply!
    The exception message is something like this:"The remote host has shutdown the connection"
    exception code is: 10054
    socketerrorsorce is:ConnectionReset
    looking forward to your reply

  • KarlaW

    Can you just post the Exeption Message

    Best Regards,



  • What's done with the Send method of UdpClient?