title: C# Client-Server implementation error on client's socket "no connection could be made..."
body: <p>I'm trying to launch my client, but have an error. Server is already running on the same computer. So I'm using "localhost" with GetHostEntry:</p>
  
  <pre><code> IPHostEntry ipHostInfo = System.Net.Dns.GetHostEntry("localhost");
   IPAddress ipAddress = ipHostInfo.AddressList[0];
   IPEndPoint remoteEP = new IPEndPoint(ipAddress, Port);
  
  Sock = new Socket(remoteEP.AddressFamily, SocketType.Stream, ProtocolType.Tcp);
  Sock.BeginConnect(remoteEP, new AsyncCallback(ConnectCallback), Sock);
  </code></pre>
  
  <p>But I have this "no connection could be made because the target machine actively refused it":</p>
  
  <pre><code>System.Net.Sockets.SocketException (0x80004005): No connection could be made because the target machine actively refused it [::1]:7777
     at System.Net.Sockets.Socket.EndConnect(IAsyncResult asyncResult)
     at NotifierClient.AsynchronousClient.ConnectCallback(IAsyncResult ar) in *** :line 156 
  </code></pre>
  
  <p>Line 156 is</p>
  
  <pre><code>client.EndConnect(ar);
  </code></pre>
  
  <p>What is the reason? Could it be because ipHostInfo.AddressList[0] is an IPv6? How then I can accept Ipv4 address?</p>