定制 yidas/socket 二次开发

按需修改功能、优化性能、对接业务系统,提供一站式技术支持

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

yidas/socket

最新稳定版本:0.1

Composer 安装命令:

composer require yidas/socket

包简介

PHP socket

README 文档

README

Modern PHP Socket class based on native infra (pure PHP, CI, Yii, Laravel support)

Latest Stable Version License

DEMONSTRATION

Client

try {

    $socket = new \yidas\socket\Client([
        'protocol' => 'tcp',
        'host' => 'smtp.your.com',
        'port' => '25',
        // 'domain' => AF_INET,
    ]);

} catch (Exception $e) {
    
    die("Failed to connect: {$e->getMessage()} (Code: {$e->getCode()})");
}

echo $socket->read();
// ...
$socket->write('STARTTLS');
echo $socket->read();
$result = $socket->enableCrypto();
// ...

$socket->close();

Native function support:

$socket = new \yidas\socket\Client();

try {

  $socket->stream_socket_client('tcp://smtp.your.com:25', $errorCode, $errorMsg, 15);

} catch (Exception $e) {
    
    die("Failed to connect: {$e->getMessage()} (Code: {$e->getCode()})");
}

$socket->fread(1024);
// ...
$socket->fwrite('STARTTLS');
echo $socket->fread(1024);
$result = $socket->stream_socket_enable_crypto(true, STREAM_CRYPTO_METHOD_TLSv1_2_CLIENT);
// ...

$socket->fclose();

统计信息

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

GitHub 信息

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

其他信息

  • 授权协议: MIT
  • 更新时间: 2024-01-08