title: socket_connect(): unable to connect [10061] - target machine actively refused it
body: <p>I am trying to connect the target written in C using PHP socket_connect() function, but I am getting the following error: </p>
  
  <p><strong>Warning: socket_connect(): unable to connect [10061]: No connection could be made because the target machine actively refused it.</strong></p>
  
  <p>This is the code what I am running: </p>
  
  <pre><code>    $service_port = 1234; 
      $address = "xx.xxx.xx.xxx";
      $socket = socket_create(AF_INET, SOCK_STREAM, SOL_TCP);     
      if ($socket === false) {
          echo "socket_create() failed: reason: " . socket_strerror(socket_last_error()) . "\n";
      } else {
          echo "OK.\n&lt;br&gt;";
      }       
      echo "Attempting to connect to '$address' on port '$service_port'...\n";        
  
      $result = socket_connect($socket, $address, $service_port);
  
      if ($result === false) {
          echo "socket_connect() failed.\nReason: ($result) " . socket_strerror(socket_last_error($socket)) . "\n";
      } else {
          echo "OK.\n&lt;br&gt;";
      }
  </code></pre>
  
  <p>I am using the xampp server with PHP 5.4 in Windows 7 and I have disabled the firewall settings. Still I am getting the same refused error. </p>
  
  <p>Please help me to solve this issue. [I am fighting with this issue for the last 3 days]</p>
  
  <p>Thanks in advance.</p>