title: No connection could be made because the target machine actively refused it 127.0.0.1:8082
body: <p>I have made a small windows service which i needs to get connected from my own localhost system but on running the application i am getting error as..</p>
  
  <pre><code>No connection could be made because the target machine actively refused it 127.0.0.1:8082
  </code></pre>
  
  <p>whereas it is perfectly working in Live ip and port numbers but i need to test it on localhost as i cant access the live running ip everytime..</p>
  
  <p>Here is my code...</p>
  
  <pre><code>byte[] data = new byte[1024];
           string input, stringData;
           String ip = "127.0.0.1";
           Int32 port = 8082;
           string path = "D:\\";
  
              if (File.Exists("ipsettings.txt"))
              {
                  File.Delete("ipsettings.txt");
              }
              IPAddress ipad = IPAddress.Parse(ip);
              IPEndPoint ipend = new IPEndPoint(ipad, port);
              Socket sock = new Socket(AddressFamily.InterNetwork, SocketType.Stream, ProtocolType.Tcp);
              try
              {
                  sock.Connect(ipend);
  
              }
              catch (Exception ex)
              {
                  throw ex;
              }
  </code></pre>
  
  <p>I am getting error at this point..</p>
  
  <pre><code> try
              {
                  sock.Connect(ipend);
  
              }
              catch (Exception ex)
              {
                  throw ex;
              }
  </code></pre>
  
  <p>Please help me to resolve the issue..
  Thanks in advance..</p>