title: No connection could be made because the target machine actively refuses it
body: <p>I'm working on a simple hello world TCP/IP client server app in C# and am unable to get my client to connect.  Can anyone offer any additional troubleshooting steps?  I'm starting to run out of ideas...</p>
  
  <p>Here are the relevant sections of code:</p>
  
  <p>server:</p>
  
  <pre><code>Console.Out.WriteLine("About to bind address");
  IPAddress ipAd = IPAddress.Parse("127.0.0.1"); 
  Console.Out.WriteLine("Choose a port to bind...");
  
  String port = Console.In.ReadLine();
  int iPort = Int32.Parse(port);
  
  TcpListener myList = new TcpListener(ipAd, iPort);
  
  myList.Start();
  
  Console.WriteLine("The server is running at: "+myList.LocalEndpoint);
  Console.WriteLine("Waiting for a connection.....");
  
  Socket s = myList.AcceptSocket();
  Console.WriteLine("Connection accepted from " + s.RemoteEndPoint);
  </code></pre>
  
  <p>client:</p>
  
  <pre><code>Console.Out.WriteLine("enter address: ");
  string address = Console.In.ReadLine();
  Console.Out.WriteLine("enter port: ");
  int port = Convert.ToInt32(Console.In.ReadLine());
  
  TcpClient tcpclnt = new TcpClient();
  Console.WriteLine("Connecting.....");
  
  Console.Out.WriteLine("Address: " + address + ":" + port);
  tcpclnt.Connect(address, port);
  </code></pre>
  
  <p>I am able to ping the server from the client machine, however I am unable to telnet to the server using the bound port.  I've tried a variety of ports (a few in the low 8000s and a few up around 40000).  I have disable windows firewall on both systems.  The systems are connected to a router which is not on the internet.  I've tried with and without port forwarding set to forward incoming requests on the given port to the server machine with no effect.</p>
  
  <p>The only exception that I've been able to trap is thrown by the client: </p>
  
  <blockquote>
    <p>No connection could be made because
    the target machine actively refuses
    it.</p>
  </blockquote>
  
  <p>I checked for an <code>InnerException</code> but it seems that there are none - that is the base exception.  Could that be right?</p>
  
  <p>Not sure what else I should be looking at - any additional troubleshooting steps would be helpful.</p>
  
  <p>Thanks!</p>