2017 © Pedro Peláez
 

library socket

ReactiveX client and server socket

image

rxnet/socket

ReactiveX client and server socket

  • Wednesday, July 18, 2018
  • by vince.ve
  • Repository
  • 1 Watchers
  • 0 Stars
  • 2,342 Installations
  • PHP
  • 1 Dependents
  • 0 Suggesters
  • 2 Forks
  • 2 Open issues
  • 3 Versions
  • 10083 % Grown

The README.md

Socket observable

FOSSA Status, (*1)

Ultra thin ReactPHP socket adapter to bring ReactiveX flavour., (*2)

Client

Low level socket that connect to remote or throw an exception
Then echo the received data has they arrive, (*3)

<?php
$connector = new \Rxnet\Socket\Connector($loop);
$options = [
    // See http://php.net/manual/en/context.socket.php for all tcp options
    'tcp'=> [
        'backlog' => 200,
        'so_reuseport' => true,
        'ipv6_v6only' => true
    ],
    // see http://php.net/manual/en/context.ssl.php for all ssl options
    'tls' => [
        'verify_peer' => false
    ]
];
$connector->connect('www.google.fr:80', $options)
    ->timeout(100)
    ->subscribe(
        function (\Rxnet\Socket\Connection $connection) use ($loop) {
            $connection
                ->subscribe(
                    function ($data) {
                        // Every chunk received will give onNext
                        var_dump($data);
                    },
                    function (\Exception $e) {
                        echo $e->getMessage();
                    },
                    function () {
                        echo 'completed';
                    }
                );
                $connection->write("GET /?gfe_rd=cr&dcr=0&ei=YWhsWsTDIZOm8wep_beACA HTTP/1.0\r\nHost: www.google.fr\r\n\r\n");
        }
    );

Server

Low level socket server that will wait one input before saying ok and closing., (*4)

<?php

$server = new \Rxnet\Socket\Server($loop);

$server->listen('0.0.0.0:9999')
    ->subscribe(function(\Rxnet\Socket\Connection $connection) {
        $connection->subscribe(function($data) use($connection) {
            echo 'received '.$data." from ".$connection->getRemoteAddress()." \n";
            $connection->end('ok');
        });
        $connection->write('Hello their');
    });

Pipe

A Connection is an Observable and an Observer, you can subscribe a connection to another to pipe data., (*5)

License

FOSSA Status, (*6)

The Versions

18/07 2018

dev-master

9999999-dev

ReactiveX client and server socket

  Sources   Download

MIT

The Requires

 

by Vincent Vermersch

tcp socket reactphp reactivex

18/07 2018

0.2.0

0.2.0.0

ReactiveX client and server socket

  Sources   Download

MIT

The Requires

 

by Vincent Vermersch

tcp socket reactphp reactivex

27/01 2018

0.1.0

0.1.0.0

ReactiveX client and server socket

  Sources   Download

MIT

The Requires

 

by Vincent Vermersch

tcp socket reactphp reactivex