Класс EventListener
по умолчанию, Libevent переключает нижележащий файловый дескриптор или сокет в неблокирующий режим. Этот флаг сообщает Libevent, что следует оставить их в блокирующем режиме.
EventListener::OPT_CLOSE_ON_FREE
Если этот флаг установлен, слушатель соединения закроет сокет когда объект EventListener будет уничтожен.
EventListener::OPT_CLOSE_ON_EXEC
Если этот флаг установлен, слушатель соединения установит флаг close-on-exec на сокет. Смотрите документацию по fcntl и FD_CLOEXEC для вашей платформы.
EventListener::OPT_REUSEABLE
На некоторых платформах, по умолчанию, после закрытия сокета, другие сокеты не смогут привязаться к тому же порту, пока не пройдёт некоторое время. Данный флаг говорит Libevent помечать сокет как переиспользуемый, что позволит открывать другие сокеты на том же порту после его закрытия.
EventListener::OPT_THREADSAFE
Выделяет блокировки для слушателя, что позволяет безопасно использовать его в многопоточном варианте.
User Contributed Notes
- Event
- Введение
- Установка и настройка
- Примеры
- Флаги событий
- О постоянных(persistent) событиях
- Callback-функции
- Создание событий для сигналов
- Event
- EventBase
- EventBuffer
- EventBufferEvent
- О callback-функциях событийного буфера
- EventConfig
- EventDnsBase
- EventHttp
- EventHttpConnection
- EventHttpRequest
- EventListener
- EventSslContext
- EventUtil
The EventListener class
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
- EventListener::__construct — Creates new connection listener associated with an event base
- EventListener::disable — Disables an event connect listener object
- EventListener::enable — Enables an event connect listener object
- EventListener::getBase — Returns event base associated with the event listener
- EventListener::getSocketName — Retreives the current address to which the listener’s socket is bound
- EventListener::setCallback — The setCallback purpose
- EventListener::setErrorCallback — Set event listener’s error callback