eio_grp_add

(PECL eio >= 0.0.1dev)

eio_grp_addAdds a request to the request group

Beschreibung

eio_grp_add(resource $grp, resource $req): void

eio_grp_add() adds a request to the request group.

Parameter-Liste

grp

The request group resource returned by eio_grp()

req

The request resource

Rückgabewerte

Es wird kein Wert zurückgegeben.

Beispiele

Beispiel #1 Grouping requests

<?php
/*
 * Create a group request to open, read and close a file
 */

// Create temporary file and write some bytes to it
$temp_filename dirname(__FILE__) ."/eio-file.tmp";
$fp fopen($temp_filename"w");
fwrite($fp"some data");
fclose($fp);

/* Is called when the group requests are done */
function my_grp_done($data$result) {
 
var_dump($result == 0);
 @
unlink($data);
}

/* Is called when eio_open() done */
function my_grp_file_opened_callback($data$result) {
 global 
$grp;

 
// $result should contain the file descriptor
 
var_dump($result 0);

 
// Create eio_read() request and add it to the group
 // Pass file descriptor to the callback
 
$req eio_read($result40,
   
EIO_PRI_DEFAULT"my_grp_file_read_callback"$result);
 
eio_grp_add($grp$req);
}

/* Is called when eio_read() done */
function my_grp_file_read_callback($data$result) {
 global 
$grp;

 
// Read bytes
 
var_dump($result);

 
// Create eio_close() request and add it to the group
 // $data should contain the file descriptor
 
$req eio_close($data);
 
eio_grp_add($grp$req);
}

// Create request group
$grp eio_grp("my_grp_done"$temp_filename);
var_dump($grp);

// Create eio_open() request and add it to the group
$req eio_open($temp_filenameEIO_O_RDWR EIO_O_APPEND NULL,
  
EIO_PRI_DEFAULT"my_grp_file_opened_callback"NULL);
eio_grp_add($grp$req);

// Process requests
eio_event_loop();
?>

Das oben gezeigte Beispiel erzeugt eine ähnliche Ausgabe wie:

resource(6) of type (EIO Group Descriptor)
bool(true)
string(4) "some"
bool(true)

Siehe auch

Hier Kannst Du einen Kommentar verfassen


Bitte gib mindestens 10 Zeichen ein.
Wird geladen... Bitte warte.
* Pflichtangabe
Es sind noch keine Kommentare vorhanden.

PHP cURL-Tutorial: Verwendung von cURL zum Durchführen von HTTP-Anfragen

cURL ist eine leistungsstarke PHP-Erweiterung, die es Ihnen ermöglicht, mit verschiedenen Servern über verschiedene Protokolle wie HTTP, HTTPS, FTP und mehr zu kommunizieren. ...

TheMax

Autor : TheMax
Kategorie: PHP-Tutorials

Midjourney Tutorial - Anleitung für Anfänger

Über Midjourney, dem Tool zur Erstellung digitaler Bilder mithilfe von künstlicher Intelligenz, gibt es ein informatives Video mit dem Titel "Midjourney Tutorial auf Deutsch - Anleitung für Anfänger" ...

Mike94

Autor : Mike94
Kategorie: KI Tutorials

Grundlagen von Views in MySQL

Views in einer MySQL-Datenbank bieten die Möglichkeit, eine virtuelle Tabelle basierend auf dem Ergebnis einer SQL-Abfrage zu erstellen. ...

admin

Autor : admin
Kategorie: mySQL-Tutorials

Tutorial veröffentlichen

Tutorial veröffentlichen

Teile Dein Wissen mit anderen Entwicklern weltweit

Du bist Profi in deinem Bereich und möchtest dein Wissen teilen, dann melde dich jetzt an und teile es mit unserer PHP-Community

mehr erfahren

Tutorial veröffentlichen

SoundCloud to MP3

SoundCloud (https://soundcloudto.com/) to MP3 converters have gained popularity as convenient tools for downloading and converting audio from Soun ...

Geschrieben von soundcloudto am 19.07.2024 04:10:40
Forum: User pages
Suche Netzwerktechnik Großhändler

I'm currently seeking reliable wholesalers specializing in network technology. Please provide details on your range of products, pricing, and any ...

Geschrieben von dussan77 am 12.07.2024 16:54:48
Forum: Ankündigungen
Getting Database Connection Failed Error in PHP Project

Hi everyone, I’m currently working on an AI and ML-based web application using PHP, and I've hit a roadblock. I’m encountering a “Database ...

Geschrieben von Gast am 27.06.2024 11:31:32
Forum: Off-Topic Diskussionen
How to overcome Safari's iframe cookie block?

Hello I think your cookies are set with SameSite=None; Secure to allow cross-site usage. To implement a custom proxy on the server side to handle ...

Geschrieben von Gast am 27.06.2024 11:04:46
Forum: HTML, JavaScript, AJAX, jQuery, CSS, Bootstrap, LESS