title: PHP Multi curl with different ports
body: <p>I am working with an IOT system and trying to improve our data ingestion. Currently we are iterating over an array of URLs with different ports and sending one curl request at a time. I would like to use multicurl to get around this bottleneck but I am getting only getting errors as a response.
  Here's my code (IP addresses redacted)</p>
  <pre><code>$url = 'http://XXX.XXX.XX.XXX/getvar.csv';
  $ports = [8101,8102,8103,8104];
  
  foreach ($ports as $port) {
          $worker = curl_init($curl_url);
          curl_setopt_array($worker, [
              CURLOPT_RETURNTRANSFER =&gt; true,
              CURLOPT_POST =&gt; true,
              CURLOPT_HEADER =&gt; 0,
              CURLOPT_TIMEOUT =&gt; 8,
              CURLOPT_POSTFIELDS =&gt; $content,
              CURLOPT_PORT =&gt; $port
          ]);
  
          curl_multi_add_handle($mh, $worker);
      }
  $i=0;
  for (; ;) {
      $still_running = null;
      echo &quot;&lt;p&gt;exec multi curl $i&lt;/p&gt;&quot;;
      do {
          echo &quot;&lt;p&gt;curl multi exec&lt;/p&gt;&quot;;
          $err = curl_multi_exec($mh, $still_running);
      } while ($err === CURLM_CALL_MULTI_PERFORM);
      if ($err !== CURLM_OK) {
          $description = curl_strerror(curl_errno($mh));
          echo &quot;&lt;p&gt;Error description: $description&lt;/p&gt;&quot;;
          // handle curl multi error?
      }
      if ($still_running &lt; 1) {
          echo &quot;&lt;p&gt;curl multi finished&lt;/p&gt;&quot;;
          // all downloads completed
          break;
      }
      // some haven't finished downloading, sleep until more data arrives:
      curl_multi_select($mh, 8);
      $i++;
  }
  
  $curl_time_stop = microtime(true);
  $curl_duration += $curl_time_stop - $curl_time_start;
  echo &quot;CURL finished&quot;;
  $results = [];
  while (false !== ($info = curl_multi_info_read($mh))) {
      if ($info[&quot;result&quot;] !== CURLE_OK) {
          echo &quot;Error &quot;.curl_strerror($info[&quot;result&quot;]);
          // handle download error?
      }
      $results[curl_getinfo($info[&quot;handle&quot;], CURLINFO_EFFECTIVE_URL)] = 
      curl_multi_getcontent($info[&quot;handle&quot;]);
      curl_multi_remove_handle($mh, $info[&quot;handle&quot;]);
      curl_close($info[&quot;handle&quot;]);
  }
  curl_multi_close($mh);
  var_dump($results);
  </code></pre>
  <p>Here's the errors/response I am getting</p>
  <pre><code>Error Server returned nothing (no headers, no data)
  results int(1) int(52) resource(29) of type (curl)
  </code></pre>
  <p>From what I can tell error code 52 corresponds to <code>CURLE_GOT_NOTHING</code>.
  Is there something I am missing? Or is there a difference in the protocols used by multi-curl vs curl?</p>
  <p>[Edit: Add verbose output]
  Here's the result when I use <code>CURLOPT_VERBOSE=&gt;1</code></p>
  <pre><code>*   Trying 1XX.XX.XX.XX:8101...
  
  * Found bundle for host 1XX.XX.XX.XX: 0x2625a00 [serially]
  * Server doesn't support multiplex (yet)
  * Hostname 1XX.XX.XX.XX was found in DNS cache
  *   Trying 1XX.XX.XX.XX:8101...
  
  *** Connected to 1XX.XX.XX.XX (1XX.XX.XX.XX) port 8101 (#0)
  &gt; POST /getvar.csv? HTTP/1.1
  Host: 1XX.XX.XX.XX:8101
  Accept: */*
  Content-Length: 248
  Content-Type: application/x-www-form-urlencoded**
  
  * Mark bundle as not supporting multiuse
  &lt; HTTP/1.1 200 OK
  &lt; Content-Type: text/csv; charset=&quot;utf-8&quot;
  &lt; Server: embedded HTTPD
  &lt; Expires: 1 JAN 2013 00:00:00 GMT
  &lt; Last-Modified: 4 MAR 2021 12:10:09 GMT
  &lt; Cache-Control: no-cache
  &lt; Transfer-Encoding: chunked
  
  * Connection #0 to host 1XX.XX.XX.XX left intact
  * Empty reply from server
  * Closing connection 25
  </code></pre>