title: Why does socket.BeginConnect() always succeed even if there is no server
body: <p>Why does Socket.BeginConnect() always succeed? I've made the following code to illustrate my point, if you run just this code there is no server listening, nothing it can possibly connect to and yet it works without problem.</p>
  
  <pre><code>private static Socket mSocket;
  static void Main(string[] args)
  {
      mSocket = new Socket(AddressFamily.InterNetwork, SocketType.Dgram, ProtocolType.Udp);
      IPEndPoint remoteEndPoint = new IPEndPoint(IPAddress.Parse("127.0.0.1"), 9050);
      mSocket.BeginConnect(remoteEndPoint.Address, remoteEndPoint.Port, new AsyncCallback(OnConnect), null);
      Console.Read();
  }
  
  static void OnConnect(IAsyncResult asyncResult)
  {
      try
      {
          mSocket.EndConnect(asyncResult);
          Console.WriteLine(mSocket.Connected);
      }
      catch(Exception ex)
      {
          Console.WriteLine(ex.Message);
      }
  }
  </code></pre>
  
  <p>Some of the System.Net.Sockets.Socket methods do not work if you use: <code>SocketType.Dgram, ProtocolType.Udp</code> like <code>Socket.Listen()</code> but Socket.Connect/BeginConnect() still do, this is nice which means the client has the exact same code for UDP as TCP (which i already have) but why? UDP is supposed to be connection less so making a connection (for me) does not make sense.</p>
  
  <p>If there was an Socket.accept which worked in accepting a UDP client that wanted to connect I might understand (because then it would stay uniform and you could use either one for TCP or UDP)</p>