2017 © Pedro Peláez
 

library zf2socket

Socket server for zend 2

image

claudiograssia/zf2socket

Socket server for zend 2

  • Tuesday, December 13, 2016
  • by claudiograssia
  • Repository
  • 1 Watchers
  • 0 Stars
  • 0 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 0 Forks
  • 0 Open issues
  • 2 Versions
  • 0 % Grown

The README.md

Zf2Socket

Installation

with Composer and install dependecies hoa\socket., (*1)

{
    "require": {
        "claudiograssia/zf2socket": "0.0.1-dev"
    }
}

The first step after installation, write into config/application.config.php, (*2)

return array(
    'modules' => array(
        "Zf2Socket",
        "Application",
        "etc"
    )
)

start test socket into terminal with this command, (*3)

myprojectzf2/public php index.php socket test

or use, (*4)

Example Use

will be use with zendframework 2., (*5)

And it is be start with console router. Create a console become this example, (*6)

module.config.php

```php return array( 'console' => array( 'router' => array( 'routes' => array( 'indexer' => array( 'options' => array( 'route' => 'socket', 'defaults' => array( 'controller' => 'Application\Controller\Index', 'action' => 'index' ) ) ) ), ), ) ) ````, (*7)

class IndexController extends AbstractActionController {

    public function indexAction() {

        $server = $this->getServerService();
        $server->init('tcp://127.0.0.1:4242', function($server) {
            $line = $server->readLine();

            if (empty($line)) {
                $server->disconnect();
                continue;
            }

            echo '< ', $line, "\n";
            $server->writeLine(strtoupper($line));
        });

    }

    /**
     * @return \Zf2Socket\Service\Server
     */
    protected function getServerService() {
        return $this->getServiceLocator()->get('SocketServer');
    }
}

Start socket with command into terminal, (*8)

myprojectzf2/public php index.php socket

and it will can be use with terminal, (*9)

$ telnet 127.0.0.1
Trying 127.0.0.1...
Connected to localhost.
Escape character is '^]'.
test
test

or it will can be use with python, (*10)

import socket
import sys

# Create a TCP/IP socket
sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM)

# Connect the socket to the port where the server is listening
server_address = ('127.0.0.1', 4242)
print >>sys.stderr, 'connecting to %s port %s' % server_address
sock.connect(server_address)

License

This library is a free project and it can be use for any project., (*11)

Attention read also license dependencies this library., (*12)

THANX FOR HAVE READ THIS DOCUMENT

The Versions

13/12 2016

dev-master

9999999-dev

Socket server for zend 2

  Sources   Download

GPL 3

The Requires

 

by claudio grassia

library zf2 server zend socket

19/06 2015

0.0.1.x-dev

0.0.1.9999999-dev

Socket server for zend 2

  Sources   Download

GPL 3

The Requires

 

by claudio grassia

library zf2 server zend socket