GithubHelp home page GithubHelp logo

php-nano's Introduction

Build Status

nanomsg extension for PHP

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. Restart FPM service or Apache web server.

!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 namespace NanoMsg with three class:

  • NanoMsg\Nano - main class
  • NanoMsg\Socket - base socket class
  • NanoMsg\Exception - utility class for Exception

For example, use it with short name:

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

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

Main class to provide socket.

methods:

  • bind
  • connect
  • shutdown
  • send
  • recv
  • setsockopt
  • getsockopt

php-nano's People

Contributors

mkoppanen avatar recoye avatar markkimsal avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.