System.Net.Sockets.UdpClient.EndSend C# (CSharp) Method

EndSend() public method

public EndSend ( IAsyncResult asyncResult ) : int
asyncResult IAsyncResult
return int
        public int EndSend(IAsyncResult asyncResult)
        {
            if (_cleanedUp)
            {
                throw new ObjectDisposedException(this.GetType().FullName);
            }

            if (_active)
            {
                return _clientSocket.EndSend(asyncResult);
            }
            else
            {
                return _clientSocket.EndSendTo(asyncResult);
            }
        }

Usage Example

Example #1
0
 public void Send()
 {
   var msg = Encoding.ASCII.GetBytes(Message);
   try {
     var client = new UdpClient();
     client.Client.Bind(new IPEndPoint(LocalAddress, 0));
     client.BeginSend(msg, msg.Length, EndPoint, result =>
     {
       try {
         client.EndSend(result);
       }
       catch (Exception ex) {
         Debug(ex);
       }
       finally {
         try {
           client.Close();
         }
         catch (Exception) {
         }
       }
     }, null);
   }
   catch (Exception ex) {
     Error(ex);
   }
   ++SendCount;
 }
All Usage Examples Of System.Net.Sockets.UdpClient::EndSend