The EventBufferEvent class

(PECL event >= 1.2.6-beta)

Einführung

Represents Libevent's buffer event.

Usually an application wants to perform some amount of data buffering in addition to just responding to events. When we want to write data, for example, the usual pattern looks like:

  1. Decide that we want to write some data to a connection; put that data in a buffer.

  2. Wait for the connection to become writable

  3. Write as much of the data as we can

  4. Remember how much we wrote, and if we still have more data to write, wait for the connection to become writable again.

This buffered I/O pattern is common enough that Libevent provides a generic mechanism for it. A "buffer event" consists of an underlying transport (like a socket), a read buffer, and a write buffer. Instead of regular events, which give callbacks when the underlying transport is ready to be read or written, a buffer event invokes its user-supplied callbacks when it has read or written enough data.

Klassenbeschreibung

final class EventBufferEvent {
/* Constants */
const int READING = 1;
const int WRITING = 2;
const int EOF = 16;
const int ERROR = 32;
const int TIMEOUT = 64;
const int CONNECTED = 128;
const int OPT_CLOSE_ON_FREE = 1;
const int OPT_THREADSAFE = 2;
const int OPT_DEFER_CALLBACKS = 4;
const int OPT_UNLOCK_CALLBACKS = 8;
const int SSL_OPEN = 0;
const int SSL_CONNECTING = 1;
const int SSL_ACCEPTING = 2;
/* Eigenschaften */
public int $fd;
public int $priority;
public readonly EventBuffer $input;
public readonly EventBuffer $output;
/* Methoden */
public close(): void
public connect( string $addr ): bool
public connectHost(
     EventDnsBase $dns_base ,
     string $hostname ,
     int $port ,
     int $family = EventUtil::AF_UNSPEC
): bool
public __construct(
     EventBase $base ,
     mixed $socket = null ,
     int $options = 0 ,
     callable $readcb = null ,
     callable $writecb = null ,
     callable $eventcb = null ,
     mixed $arg = null
)
public static createPair( EventBase $base , int $options = 0 ): array
public disable( int $events ): bool
public enable( int $events ): bool
public free(): void
public getDnsErrorString(): string
public getEnabled(): int
public read( int $size ): string
public readBuffer( EventBuffer $buf ): bool
public setCallbacks(
     callable $readcb ,
     callable $writecb ,
     callable $eventcb ,
     mixed $arg = ?
): void
public setPriority( int $priority ): bool
public setTimeouts( float $timeout_read , float $timeout_write ): bool
public setWatermark( int $events , int $lowmark , int $highmark ): void
public sslError(): string
public static sslFilter(
     EventBase $base ,
     EventBufferEvent $underlying ,
     EventSslContext $ctx ,
     int $state ,
     int $options = 0
): EventBufferEvent
public sslGetCipherInfo(): string
public sslGetCipherName(): string
public sslGetCipherVersion(): string
public sslGetProtocol(): string
public sslRenegotiate(): void
public static sslSocket(
     EventBase $base ,
     mixed $socket ,
     EventSslContext $ctx ,
     int $state ,
     int $options = ?
): EventBufferEvent
public write( string $data ): bool
public writeBuffer( EventBuffer $buf ): bool
}

Eigenschaften

fd

Numeric file descriptor associated with the buffer event. Normally represents a bound socket. Equals to null, if there is no file descriptor(socket) associated with the buffer event.

priority

The priority of the events used to implement the buffer event.

input

Underlying input buffer object( EventBuffer )

output

Underlying output buffer object( EventBuffer )

Vordefinierte Konstanten

EventBufferEvent::READING

An event occurred during a read operation on the bufferevent. See the other flags for which event it was.

EventBufferEvent::WRITING

An event occurred during a write operation on the bufferevent. See the other flags for which event it was.

EventBufferEvent::EOF

Got an end-of-file indication on the buffer event.

EventBufferEvent::ERROR

An error occurred during a bufferevent operation. For more information on what the error was, call EventUtil::getLastSocketErrno() and/or EventUtil::getLastSocketError() .

EventBufferEvent::TIMEOUT

EventBufferEvent::CONNECTED

Finished a requested connection on the bufferevent.

EventBufferEvent::OPT_CLOSE_ON_FREE

When the buffer event is freed, close the underlying transport. This will close an underlying socket, free an underlying buffer event, etc.

EventBufferEvent::OPT_THREADSAFE

Automatically allocate locks for the bufferevent, so that it’s safe to use from multiple threads.

EventBufferEvent::OPT_DEFER_CALLBACKS

When this flag is set, the bufferevent defers all of its callbacks. See » Fast portable non-blocking network programming with Libevent, Deferred callbacks .

EventBufferEvent::OPT_UNLOCK_CALLBACKS

By default, when the bufferevent is set up to be threadsafe, the buffer event’s locks are held whenever the any user-provided callback is invoked. Setting this option makes Libevent release the buffer event’s lock when it’s invoking the callbacks.

EventBufferEvent::SSL_OPEN

The SSL handshake is done

EventBufferEvent::SSL_CONNECTING

SSL is currently performing negotiation as a client

EventBufferEvent::SSL_ACCEPTING

SSL is currently performing negotiation as a server

Inhaltsverzeichnis

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

Notizen-App: was ist eure - ich komm immer wieder auf Keep zurück...

Hallo liebe Community, guten Abend, Notizen-App: was ist eure - ich komm immer wieder auf Keep zurück... was ist eure beste NoteTaking App!? i ...

Geschrieben von dhubs am 22.12.2024 23:05:11
Forum: Off-Topic Diskussionen
How to overcome Safari's iframe cookie block?

To overcome Safari's iframe cookie block, you can use the SameSite=None; Secure cookie attribute in conjunction with a third-party domain that sup ...

Geschrieben von Joniemartinez am 21.12.2024 13:28:24
Forum: HTML, JavaScript, AJAX, jQuery, CSS, Bootstrap, LESS
Probleme mit speichern in Datenbank in französisch

Les erreurs fréquentes lors de l'enregistrement de données dans une base de données incluent des problèmes de connexion, des erreurs de syntax ...

Geschrieben von Alice12 am 18.12.2024 05:07:21
Forum: PHP Developer Forum
Gibt es eine API zum Abrufen von PHP-Code-Referenzen?

PHP.net bietet eine umfassende Online-Dokumentation für PHP. Es gibt keine offizielle API zum Abrufen von PHP-Dokumentationen direkt, aber du kan ...

Geschrieben von Alice12 am 18.12.2024 05:03:27
Forum: PHP Developer Forum