Skip to content

Instantly share code, notes, and snippets.

@masakielastic
masakielastic / QuicInitialPacketParser.php
Created March 5, 2026 03:37
QUIC Initial Packet Parser (PHP)
<?php
declare(strict_types=1);
final class QuicInitialPacketParser
{
private string $buffer = '';
private int $offset = 0;
public function parse(string $packet): array
@masakielastic
masakielastic / README.md
Created March 4, 2026 06:58
Zig 0.15.2 で TCP クライアント

Zig 0.15.2 で TCP クライアント

zig run client.zig
@masakielastic
masakielastic / README.md
Last active March 4, 2026 06:33
Zig 0.15.2 で HTTP クライアント

Zig 0.15.2 で HTTP クライアント

zig run client.zig
@masakielastic
masakielastic / README.md
Created March 4, 2026 05:06
Zig 0.15 系で HTTP/1 サーバー

Zig 0.15 系で HTTP/1 サーバー

zig run server.zig
curl -v http//localhost:3000
@masakielastic
masakielastic / README.md
Last active March 3, 2026 23:08
PHP のストリーム関数で簡易 HTTP/2 クライアント・オブジェクト指向

PHP のストリーム関数で簡易 HTTP/2 クライアント・オブジェクト指向

target: tls://104.18.26.120:443 (SNI/peer_name=example.com)
alpn_protocols(configured): h2,http/1.1
ALPN (negotiated): h2
>>> sending client preface (24 bytes)
>>> sending SETTINGS (empty payload)
FRAME #0 len=18 type=0x04(SETTINGS) flags=0x00 sid=0
0000  00 03 00 00 00 64 00 04 00 01 00 00 00 05 00 ff  .....d..........
@masakielastic
masakielastic / README.md
Created March 3, 2026 22:43
PHP のストリーム関数で簡易 HTTP/2 クライアント改善版

PHP のストリーム関数で簡易 HTTP/2 クライアント改善版

target: tls://104.18.27.120:443 (SNI/peer_name=example.com)
alpn_protocols(configured): h2,http/1.1
ALPN (negotiated): h2
>>> sending client preface (24 bytes)
>>> sending SETTINGS (empty payload)
FRAME #0 len=18 type=0x04(SETTINGS) flags=0x00 sid=0
0000  00 03 00 00 00 64 00 04 00 01 00 00 00 05 00 ff  .....d..........
@masakielastic
masakielastic / README.md
Created March 3, 2026 22:27
PHP のストリーム関数で簡易 HTTP/2 クライアント (SETTINGS まで)

PHP のストリーム関数で簡易 HTTP/2 クライアント (SETTINGS まで)

実行結果

target: tls://142.250.192.164:443 (SNI/peer_name=www.google.com)
alpn_protocols(configured): h2,http/1.1
ALPN (negotiated): h2
>>> sending client preface (24 bytes)
&gt;&gt;&gt; sending SETTINGS (empty payload)
@masakielastic
masakielastic / README.md
Created March 3, 2026 21:59
PHP のストリーム関数で簡易の HTTP/2 クライアント

PHP のストリーム関数で簡易の HTTP/2 クライアント

通信結果

=== stream_get_meta_data() ===
crypto: array (
  'protocol' => 'TLSv1.3',
  'cipher_name' => 'TLS_AES_256_GCM_SHA384',
  'cipher_bits' => 256,
@masakielastic
masakielastic / README.md
Last active March 3, 2026 05:21
HTTP/3 関連のローカルビルドのための設定ファイル・改訂版

HTTP/3 関連のローカルビルドのための設定ファイル・改訂版

OpenSSL のビルドオプションを修正して $HOME/.local/lib にインストールされるようにする。

./Configure \
  --prefix=$HOME/.local \
  --openssldir=$HOME/.local/ssl \
  --libdir=lib \
 linux-x86_64 shared zlib
@masakielastic
masakielastic / README.md
Created March 2, 2026 09:29
io_uring でエコーサーバー

io_uring でエコーサーバー

sudo apt update
sudo apt install -y build-essential liburing-dev
gcc -O2 -Wall -Wextra -pedantic -std=c11 -o uring_echo uring_echo.c -luring
./uring_echo 12345