In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-01-17 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >
Share
Shulou(Shulou.com)06/03 Report--
This article mainly shows you "what is the use of Libevent extension in PHP", the content is simple and clear, and I hope it can help you solve your doubts, so let me lead you to study and learn "what is the use of Libevent extension in PHP".
1. Libevent introduction
Libevent is an event-triggered network library, which is suitable for windows, linux, freebsd and other platforms. It uses select, poll, epoll, kqueue and other system calls to manage event mechanisms internally. Libevent is cross-platform and has extraordinary performance. Event-driven like nodejs; official website: http://libevent.org/
The latest stable version
Https://github.com/downloads/libevent/libevent/libevent-2.0.16-stable.tar.gz
Main modules:
Event handling framework
Event engine module
Buffer management module
Signal processing module
Php itself does not support multithreading, and php does not implement the concurrency mechanism very well. Pecl provides pcntl (process control), libevent extensions, socket packages, stream system functions, you can easily use php to develop high-performance, high-concurrency network applications.
Simple application example: Pcntl fork n worker. After the master process receives the request, the processing information is sent to the worker program, and the worker is processed and sent back to client. Master process can follow the concurrency to set the number of worker, that is, the size of n, and monitor (monitor) worker data to start more processes when insufficient. Same as nginx principle.
Attached: Php network programming framework
Http://code.google.com/p/swoole/downloads/list
2. Why learn libevent
Http server can be said to be a classic application of libevent. The standard way to write http can be found in libevent, non-blocking http server, that is, socket processing and http protocol processing winding.
Learning libevent helps to improve programming skills. In addition to network programming, Libevent code has many useful design skills and basic data structures, such as information hiding, function pointers, polymorphic support of c language, linked lists and heaps, etc., all help to improve their programming skills [1].
Three types of processing of requests:
1 、 connection input fork a new process
2 、 connection input pthread_create
3 、 connection input throw an Event-based array; main process do nonblocking things
3. Php libevent expansion module installation
Curl-O https://github.com/downloads/libevent/libevent/libevent-2.0.16-stable.tar.gz
Tar-zxvf libevent-2.0.16-stable.tar.gz
Cd libevent-2.0.16-stable
/ usr/local/php/bin/phpize
. / configure
Make
Make install
Vi / usr/local/php/etc/php.ini
Extension_dir= ""
Extension=libevent.so
Php-m | grep lib
Installation succeeded
The above is all the content of the article "what is the use of Libevent extensions in PHP". Thank you for reading! I believe we all have a certain understanding, hope to share the content to help you, if you want to learn more knowledge, welcome to follow the industry information channel!
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.