The EventBufferEvent class
(PECL event >= 1.2.6-beta)
Introduction
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:
-
Decide that we want to write some data to a connection; put that data in a buffer.
-
Wait for the connection to become writable
-
Write as much of the data as we can
-
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.
Synopsis de la classe
$dns_base
,
string
$hostname
,
int
$port
[,
int
$family
= EventUtil::AF_UNSPEC
] )$base
[,
mixed
$socket
= NULL
[,
int
$options
= 0
[,
callable
$readcb
= NULL
[,
callable
$writecb
= NULL
[,
callable
$eventcb
= NULL
]]]]] )$readcb
,
callable
$writecb
,
callable
$eventcb
[,
string
$arg
] )$base
,
EventBufferEvent
$underlying
,
EventSslContext
$ctx
,
int
$state
[,
int
$options
= 0
] )$base
,
mixed
$socket
,
EventSslContext
$ctx
,
int
$state
[,
int
$options
] )Propriétés
- 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 )
Constantes pré-définies
-
EventBufferEvent::READING
-
An event occured during a read operation on the bufferevent. See the other flags for which event it was.
-
EventBufferEvent::WRITING
-
An event occured 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 buffe revent 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
Sommaire
- EventBufferEvent::connect — Connecte le descripteur de fichier du tampon d'événement à l'adresse fournie, ou au socket UNIX
- EventBufferEvent::connectHost — Connexion à un hôte
- EventBufferEvent::__construct — Construit un objet EventBufferEvent
- EventBufferEvent::createPair — Crée deux événements de tampon connectés l'un à l'autre
- EventBufferEvent::disable — Désactive les événements de lecture, d'écriture ou des deux sur un événement de tampon
- EventBufferEvent::enable — Active les événements de lecture, d'écriture, ou des deux, sur un événement de tampon
- EventBufferEvent::free — Libère un événement de tampon
- EventBufferEvent::getDnsErrorString — Retourne une chaîne décrivant la dernière erreur DNS
- EventBufferEvent::getEnabled — Retourne un masque d'événements actuellement actifs sur le tampon d'événements
- EventBufferEvent::getInput — Retourne le tampon d'entrée associé avec le tampon d'événements courant
- EventBufferEvent::getOutput — Retourne le tampon de sortie associé avec le tampon d'événement courant
- EventBufferEvent::read — Lit les données du tampon
- EventBufferEvent::readBuffer — Vide le contenu entier du tampon d'entrée et le place dans le tampon
- EventBufferEvent::setCallbacks — Assigne les fonctions de rappel pour la lecture, l'écriture, et les statuts d'événements
- EventBufferEvent::setPriority — Assigne une priorité pour un tampon d'événements
- EventBufferEvent::setTimeouts — Défini le mode lecture et écriture pour le délai d'attente maximal d'un tampon d'événement
- EventBufferEvent::setWatermark — Active la lecture, et/ou l'écriture des filigranes
- EventBufferEvent::sslError — Retourne l'erreur OpenSSL la plus récente rapportée par le tampon d'événement
- EventBufferEvent::sslFilter — Crée un nouveau tampon d'événement SSL, dont les données seront envoyées via un autre tampon d'événement
- EventBufferEvent::sslRenegotiate — Demande au tampon d'événement de commencer une renégociation SSL
- EventBufferEvent::sslSocket — Crée un nouveau tampon SSL dont ces données seront envoyées via un socket SSL
- EventBufferEvent::write — Ajoute des données dans un tampon d'événement de sortie
- EventBufferEvent::writeBuffer — Ajoute le contenu entier d'un tampon dans un tampon d'événement de sortie