大网数据广告活动
PHP 语言与运行手册

The EventListener class

· 52CE 我爱测

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

The EventListener class

(PECL event >= 1.5.0)

Introduction

Represents a connection listener.

Class synopsis

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

Properties

fd

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

Predefined Constants

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.

Table of Contents

来源:PHP Documentation Group · 作者与贡献记录 · CC BY 3.0。离线整理了版式、链接和媒体显示。

资料来源与适用范围

资料来源
PHP Documentation Group
适用范围
请按文中版本与环境说明核对
内容语言
中文;命令、路径和错误标识保留技术原文
本地收录日期
2026-11-15
授权说明
CC BY 3.0

正文与所需资源由本站本地存储。查看来源及更新记录 ↗

请按适用版本和实际日志确认原因;本站没有对每一种系统或设备逐项执行文中的操作。