略微加速

PHP官方手册 - 互联网笔记

PHP - Manual: EventListener

2024-11-14

The EventListener class

(PECL event >= 1.5.0)

简介

Represents a connection listener.

类摘要

final class EventListener {
/* Constants */
const int OPT_CLOSE_ON_FREE = 2;
const int OPT_CLOSE_ON_EXEC = 4;
const int OPT_REUSEABLE = 8;
const int OPT_THREADSAFE = 16;
/* 属性 */
public readonly int $fd;
/* 方法 */
public __construct(
     EventBase $base ,
     callable $cb ,
     mixed $data ,
     int $flags ,
     int $backlog ,
     mixed $target
)
public disable(): bool
public enable(): bool
public getBase(): void
public static getSocketName( string &$address , mixed &$port = ?): bool
public setCallback( callable $cb , mixed $arg = null ): void
public setErrorCallback( string $cb ): void
}

属性

fd

Numeric file descriptor of the underlying socket. (Added in event-1.6.0 .)

预定义常量

EventListener::OPT_LEAVE_SOCKETS_BLOCKING

By default Libevent turns underlying file descriptors, or sockets, to non-blocking mode. This flag tells Libevent to leave them in blocking mode.

EventListener::OPT_CLOSE_ON_FREE

If this option is set, the connection listener closes its underlying socket when the EventListener object is freed.

EventListener::OPT_CLOSE_ON_EXEC

If this option is set, the connection listener sets the close-on-exec flag on the underlying listener socket. See platform documentation for fcntl and FD_CLOEXEC for more information.

EventListener::OPT_REUSEABLE

By default on some platforms, once a listener socket is closed, no other socket can bind to the same port until a while has passed. Setting this option makes Libevent mark the socket as reusable, so that once it is closed, another socket can be opened to listen on the same port.

EventListener::OPT_THREADSAFE

Allocate locks for the listener, so that it’s safe to use it from multiple threads.

目录

add a noteadd a note

User Contributed Notes

There are no user contributed notes for this page.

官方地址:https://www.php.net/manual/en/class.eventlistener.php

北京半月雨文化科技有限公司.版权所有 京ICP备12026184号-3