承接 rxnet/socket 相关项目开发

从需求分析到上线部署,全程专人跟进,保证项目质量与交付效率

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

rxnet/socket

Composer 安装命令:

composer require rxnet/socket

包简介

ReactiveX client and server socket

README 文档

README

FOSSA Status

Ultra thin ReactPHP socket adapter to bring ReactiveX flavour.

Client

Low level socket that connect to remote or throw an exception
Then echo the received data has they arrive

<?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.

<?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.

License

FOSSA Status

统计信息

  • 总下载量: 60.32k
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 0
  • 点击次数: 0
  • 依赖项目数: 0
  • 推荐数: 0

GitHub 信息

  • Stars: 0
  • Watchers: 0
  • Forks: 3
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2018-01-27

承接程序开发

PHP开发

VUE

Vue开发

前端开发

小程序开发

公众号开发

系统定制

数据库设计

云部署

网站建设

安全加固