18.5 | Live servers: 18.8.22 | Test servers:


AunoAsyncHttp is a PHP class for handling multiple http requests asynchronously in a non-blocking manner.

Download AunoAsyncHttp

Sample usage of AunoAsyncHttpMulti:

      /* Create a new AunoAsyncHttpMulti object, you generally need only one
       * of these in one application, and might want to implement the
       * functionality yourself using the basic AunoAsyncHttp objects.
      $http = new AunoAsyncHttpMulti;
      /* Create two http requests, arguments are
       * url, callback-object, callback-method, optional arguments
      $http->get("", $ob=NULL, "http_cb", "r1");
      $http->get("", $ob=NULL, "http_cb", "r2");
      /* Main event loop, keep going as long as we have valid event
       * sources available (which are just the two http requests in
       * this example.  In a real application the AOChat socket would
       * be appended to the $fdr array before select()
       * /
        /* $http->fdr and $http->fdw contain arrays of sockets that the
         * AunoAsyncHttpMulti object is holding and wants to get events for.
         * 'fdr' is list of sockets that are waiting for data and 'fdw' is
         * list of sockets that we want to write data to (connecting)
        $fdr = $http->fdr;
        $fdw = $http->fdw;
        /* Bail out when we are out of event sources */
        if(sizeof($fdr) + sizeof($fdw) == 0)
        if(socket_select($fdr, $fdw, $fde=NULL, 10))
          /* Ok, something has happened, $fdr and $fdw contain the lists of
           * sockets that received events, give them to AunoAsyncHttpMulti
           * for processing.
          $http->iteration($fdr, $fdw);
      /* This is the callback function we specify above.  It gets called
       * when the http requests have been completed.
       * Argument list is: http-body, http-header, optional arguments that
       * were given when the request was made (r1 for funcom and r2 for
       * in this case.
      function http_cb($body, $head, $args)
        echo "Completed HTTP request $args\n";

Revision history:

1.3: First public release