title: connect to a port address via curl and php
body: <p>I'm developing a php site using CURL,but it only works on my local server and not on live server.It returns an error 'could not connect to host'</p>
  
  <p>CURL iS installed on live server and i have tested that.</p>
  
  <p>SSL is installed on live server and I am connecting to port 9301 using curl</p>
  
  <p>ie;http://xx.xxx.xx.xxx:9301/test.</p>
  
  <p>Here is my code:</p>
  
  <pre><code>    $request =  'http://xx.xxx.xx.xxx:9301/test'; 
      // The request parameters 
      $context = 'something'; 
  
      // urlencode and concatenate the POST arguments 
      $postargs = 'xmlRequest='.urlencode($context);
      $session = curl_init($request); 
     // Tell curl to use HTTP POST
      curl_setopt ($session, CURLOPT_POST, true); 
      // Tell curl that this is the body of the POST
      curl_setopt($ch, CURLOPT_PORT, '9301');
  
  
      curl_setopt ($session, CURLOPT_POSTFIELDS, $postargs); 
      // Tell curl not to return headers, but do return the response
      curl_setopt($session, CURLOPT_HEADER, false); 
      curl_setopt($session, CURLOPT_RETURNTRANSFER, true);
  
      $response = curl_exec($session); 
     //echo curl_getinfo($session);   
      echo $err = 'Curl error: ' . curl_error($session);
     curl_close($session); 
     echo $response;
  </code></pre>
  
  <p>From my testing it's clear that i can't connect to a port address via Curl. In order to connect to the port address, need to change any server settings?</p>