Home >Backend Development >PHP Tutorial >PHP_EOL uses Apache Mina framework practice_PHP tutorial

PHP_EOL uses Apache Mina framework practice_PHP tutorial

WBOY
WBOYOriginal
2016-07-12 09:03:41918browse

PHP_EOL uses Apache Mina framework practice

1. Why use the Apache Mina framework?
ApacheMina Server is a network communication application framework. Mina can help us quickly develop high-performance, highly scalable network communication applications. Mina provides event-driven and asynchronous (Mina's asynchronous IO uses JAVANIO as the underlying support by default) Programming model of operations.
2.ApacheMina framework usage
Mina’s execution process:
> IoService: This interface is responsible for the establishment of the socket on a thread, has its own Selector, and monitors whether a connection is established.
> IoProcessor: This interface is on another thread and is responsible for checking whether there is data to read or write on the channel. That is to say, it also has its own Selector. This is a difference from when we use JAVA NIO coding. , usually in JAVA NIO coding, we all use a Selector, that is, we do not distinguish between the two functional interfaces IoService and IoProcessor. In addition, IoProcessor is responsible for calling filters registered on IoService and calling IoHandler after the filter chain.
>IoFilter: This interface defines a set of interceptors. These interceptors can include log output, blacklist filtering, data encoding (write direction) and decoding (read direction) and other functions. The encode and decode of data are The most important thing is also the main thing you pay attention to when using Mina.
>IoHandler: This interface is responsible for writing business logic, which is where data is received and sent.
Line break
For unix series n
For windows series rn
r for mac
PHP can be replaced by PHP_EOL to improve the source code portability of the code
For example:
echo PHP_EOL;
//Windows platform is equivalent to echo “rn”;
//The unixlinux platform is equivalent to echo “n”;
//Mac platform is equivalent to echo “r”;
?>
Similarly commonly used ones include
DIRECTORY_SEPARATOR
You can use the function get_defined_constants() to get all PHP constants

www.bkjia.comtruehttp: //www.bkjia.com/PHPjc/1078283.htmlTechArticlePHP_EOL Practice using the Apache Mina framework 1. Why use the Apache Mina framework? ApacheMina Server is a network communication application framework, Mina It can help us quickly develop high performance and high scalability...
Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn