From 69a6047980e9ccaf2f8c5f96f7b62c9043869b4d Mon Sep 17 00:00:00 2001 From: Alexandr Lozovyuk Date: Wed, 10 Jun 2015 21:54:55 +0300 Subject: [PATCH 1/5] Update README.md --- README.md | 23 ++++++++++++++++++++++- 1 file changed, 22 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index 6ccf6ec..4514d0f 100644 --- a/README.md +++ b/README.md @@ -3,4 +3,25 @@ nanomsg extension for PHP ========================= -For more information about nanomsg see: http://nanomsg.org/ \ No newline at end of file +For more information about nanomsg see: http://nanomsg.org/ + +How to install +========================= + +1. Install nanomsg library, see: https://github.com/nanomsg/nanomsg +2. Install PHP dev tools for extension: sudo apt-get install php5-dev (for Debian/Ubuntu) or sudo yum install php-devel (Fedora) +3. Clone repo at your server, e.g. cd /var/tmp && git clone https://github.com/nanomsg/nanomsg +4. cd /var/tmp/php-nano +5. phpize +6. configure --enable-nano +7. make +8. make install +9. Edit your php.ini file, add extension=nano.so +10. Reload fpm service + + +Base classes and methods +========================= + + + From d59560f34ea58e4c21a11428b41f772b22ef9e7b Mon Sep 17 00:00:00 2001 From: Alexandr Lozovyuk Date: Wed, 10 Jun 2015 22:24:30 +0300 Subject: [PATCH 2/5] Update README.md --- README.md | 39 +++++++++++++++++++++++++++++++++++++++ 1 file changed, 39 insertions(+) diff --git a/README.md b/README.md index 4514d0f..8444305 100644 --- a/README.md +++ b/README.md @@ -20,8 +20,47 @@ How to install 10. Reload fpm service +!Note! testd with PHP 5.6.2 only ( PHP_VERSION : 5.6.9-0+deb8u1 ZEND_VERSION: 2.6.0 ) + Base classes and methods ========================= +php-nano exposed three global class: + +* NanoMsg\Nano - main class +* NanoMsg\Socket - base socket class +* NanoMsg\Exception - utility class for Exception + +For example, use it with short name: + +```php +use NanoMsg\Nano as Nano; +use NanoMsg\Socket as NanoSocket; +use NanoMsg\Exception as NanoException; +``` + +NanoMsg\Nano +========================= + +Base class. Provide static function device (see: http://nanomsg.org/v0.5/nn_device.3.html) + +Also provided some static constant: + +domain of creating socket (see: http://nanomsg.org/v0.5/nn_socket.3.html) +* Nano::AF_SP - Standard full-blown SP socket +* Nano::AF_SP_RAW - Raw SP socket. Raw sockets omit the end-to-end functionality found in AF_SP sockets and thus can be used to implement intermediary devices in SP topologies. + +protocol parameter defines the type of the socket, which in turn determines the exact semantics of the socket + +* Nano::NN_PAIR (see: http://nanomsg.org/v0.5/nn_pair.7.html) Pair protocol is the simplest and least scalable scalability protocol. It allows scaling by breaking the application in exactly two pieces +* Nano::NN_REQ and ::NN_REQ (see: http://nanomsg.org/v0.5/nn_reqrep.7.html) This protocol is used to distribute the workload among multiple stateless workers +* Nano::NN_PUB and Nano::NN_SUB (see: http://nanomsg.org/v0.5/nn_pubsub.7.html) Broadcasts messages to multiple destinations. +* Nano::NN_SURVEYOR and Nano::NN_RESPONDENT (see: http://nanomsg.org/v0.5/nn_survey.7.html) +* Nano::NN_PUSH and Nano::NN_PULL (see: http://nanomsg.org/v0.5/nn_pipeline.7.html) +* Nano::NN_BUS (see: http://nanomsg.org/v0.5/nn_bus.7.html) + + +NanoMsg\Nano +========================= From 9e83bc7ba2e7a722aab701b0460a4b4bc069cd12 Mon Sep 17 00:00:00 2001 From: Alexandr Lozovyuk Date: Wed, 10 Jun 2015 22:29:48 +0300 Subject: [PATCH 3/5] Update README.md --- README.md | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index 8444305..ddbb676 100644 --- a/README.md +++ b/README.md @@ -60,7 +60,17 @@ protocol parameter defines the type of the socket, which in turn determines the * Nano::NN_BUS (see: http://nanomsg.org/v0.5/nn_bus.7.html) -NanoMsg\Nano +NanoMsg\Socket ========================= +Main class to provide socket. + +methods: +* bind +* connect +* shutdown +* send +* recv +* setsockopt +* getsockopt From d702bc69c5f02f25add2f2f9c7dd29b5938e4cc0 Mon Sep 17 00:00:00 2001 From: Alexandr Lozovyuk Date: Thu, 11 Jun 2015 11:07:37 +0300 Subject: [PATCH 4/5] Update README.md some cleanup --- README.md | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index ddbb676..7ad6993 100644 --- a/README.md +++ b/README.md @@ -17,15 +17,15 @@ How to install 7. make 8. make install 9. Edit your php.ini file, add extension=nano.so -10. Reload fpm service +10. Restart FPM service or Apache web server. -!Note! testd with PHP 5.6.2 only ( PHP_VERSION : 5.6.9-0+deb8u1 ZEND_VERSION: 2.6.0 ) +!Note! tested with PHP 5.6.2 only ( PHP_VERSION : 5.6.9-0+deb8u1 ZEND_VERSION: 2.6.0 ). PHP must support Namespace (PHP 5 >= 5.3.0, see: http://php.net/manual/en/language.namespaces.php) Base classes and methods ========================= -php-nano exposed three global class: +php-nano exposed namespace NanoMsg with three class: * NanoMsg\Nano - main class * NanoMsg\Socket - base socket class From d24e73a4e6fea7d85f6732a365c149322d2216c1 Mon Sep 17 00:00:00 2001 From: Alexandr Lozovyuk Date: Fri, 12 Jun 2015 00:09:42 +0300 Subject: [PATCH 5/5] Update README.md add network protocol description --- README.md | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index 7ad6993..1ec75ab 100644 --- a/README.md +++ b/README.md @@ -50,7 +50,7 @@ domain of creating socket (see: http://nanomsg.org/v0.5/nn_socket.3.html) * Nano::AF_SP - Standard full-blown SP socket * Nano::AF_SP_RAW - Raw SP socket. Raw sockets omit the end-to-end functionality found in AF_SP sockets and thus can be used to implement intermediary devices in SP topologies. -protocol parameter defines the type of the socket, which in turn determines the exact semantics of the socket +Protocol parameter defines the type of the socket, which in turn determines the exact semantics of the socket * Nano::NN_PAIR (see: http://nanomsg.org/v0.5/nn_pair.7.html) Pair protocol is the simplest and least scalable scalability protocol. It allows scaling by breaking the application in exactly two pieces * Nano::NN_REQ and ::NN_REQ (see: http://nanomsg.org/v0.5/nn_reqrep.7.html) This protocol is used to distribute the workload among multiple stateless workers @@ -59,6 +59,18 @@ protocol parameter defines the type of the socket, which in turn determines the * Nano::NN_PUSH and Nano::NN_PULL (see: http://nanomsg.org/v0.5/nn_pipeline.7.html) * Nano::NN_BUS (see: http://nanomsg.org/v0.5/nn_bus.7.html) +Nanomsg library support 4 network/communication protocol at now: + +* inproc (e.g.: inproc://example) - for in-process low-latency communication at same machine. +* ipc (e.g.: ipc://example) - for inter-process communication at same machine. +* tcp (e.g.: tcp://127.0.0.1:8081) - for tcp communication over LAN/WAN. +* ws (e.g.: ws://127.0.0.1:8081) - use WebSocket protocol over TCP. Current release, 0.5.х not supported WS, only latest build from master. + +Performance note: ipc vs inproc at same machine has 2х - 4х slow (tested NN_PAIR socket), tcp vs ipc 3х - 5х slow, and ws same as tcp at performance. + +For tcp and ws protocol, for bind method, valid IP (not domain name) and port required. For connect - you may use domain name as adress. More see: http://nanomsg.org/v0.5/nn_tcp.7.html + + NanoMsg\Socket =========================