varion/driver-stream 问题修复 & 功能扩展

解决BUG、新增功能、兼容多环境部署,快速响应你的开发需求

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

varion/driver-stream

最新稳定版本:v0.1.0

Composer 安装命令:

composer require varion/driver-stream

包简介

PHP stream driver for the Varion Transport API

README 文档

README

varion/driver-stream is a stream-based transport driver for the experimental Varion Transport API.

It is the first concrete driver implementation for varion/transport-contracts, built only with standard PHP stream/socket functions.

Scope

This package currently provides:

  • outgoing TCP connections
  • listening TCP servers
  • read/write operations
  • close operations
  • local/remote address retrieval

This is a v0.1 reference implementation and uses blocking I/O by default.

Requirements

  • PHP ^8.1
  • varion/transport-contracts ^0.1

Supported options

StreamDriver::connect(string $uri, array $options = [])

  • timeout (int|float): connection timeout seconds
  • context (array): stream context options
  • flags (int): flags for stream_socket_client()
  • blocking (bool): applies stream_set_blocking() after connection

StreamDriver::listen(string $uri, array $options = [])

  • context (array): stream context options
  • flags (int): flags for stream_socket_server()
  • backlog (int): mapped to context['socket']['backlog']
  • blocking (bool): applies stream_set_blocking() after listener creation

Usage

<?php

declare(strict_types=1);

use Varion\Transport\Driver\Stream\StreamDriver;

$driver = new StreamDriver();

$conn = $driver->connect('tcp://127.0.0.1:8080');
$conn->write("hello\n");
echo $conn->read(1024);
$conn->close();

Server example:

<?php

declare(strict_types=1);

use Varion\Transport\Driver\Stream\StreamDriver;

$driver = new StreamDriver();

$listener = $driver->listen('tcp://127.0.0.1:8080');

while ($conn = $listener->accept()) {
    $data = $conn->read(1024);
    $conn->write("HTTP/1.0 200 OK\r\nContent-Length: 2\r\n\r\nOK");
    $conn->close();
}

Limitations

  • blocking I/O oriented design
  • no TLS abstraction layer beyond native stream context options
  • no event loop integration

统计信息

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

GitHub 信息

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

其他信息

  • 授权协议: MIT
  • 更新时间: 2026-03-07

承接程序开发

PHP开发

VUE

Vue开发

前端开发

小程序开发

公众号开发

系统定制

数据库设计

云部署

网站建设

安全加固