Skip to content

streams: add so_rcvbuf and so_sndbuf socket context options. - #23406

Closed
devnexen wants to merge 3 commits into
php:masterfrom
devnexen:stream_stf_so_buf
Closed

streams: add so_rcvbuf and so_sndbuf socket context options.#23406
devnexen wants to merge 3 commits into
php:masterfrom
devnexen:stream_stf_so_buf

Conversation

@devnexen

Copy link
Copy Markdown
Member

They set SO_RCVBUF and SO_SNDBUF in bytes on TCP and UDP sockets, applied before connect() and listen(). Values outside 1 to INT_MAX throw a ValueError.

Comment on lines +11 to +23
} catch (ValueError $e) {
echo $e::class, ': ', $e->getMessage(), PHP_EOL;
}
}
}

$context = stream_context_create(['socket' => ['so_rcvbuf' => 0]]);
try {
@stream_socket_client("tcp://127.0.0.1:1", $errno, $errstr, 1,
STREAM_CLIENT_CONNECT, $context);
} catch (ValueError $e) {
echo $e::class, ': ', $e->getMessage(), PHP_EOL;
}

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
} catch (ValueError $e) {
echo $e::class, ': ', $e->getMessage(), PHP_EOL;
}
}
}
$context = stream_context_create(['socket' => ['so_rcvbuf' => 0]]);
try {
@stream_socket_client("tcp://127.0.0.1:1", $errno, $errstr, 1,
STREAM_CLIENT_CONNECT, $context);
} catch (ValueError $e) {
echo $e::class, ': ', $e->getMessage(), PHP_EOL;
}
} catch (Throwable $e) {
echo $e::class, ': ', $e->getMessage(), "\n";
}
}
}
$context = stream_context_create(['socket' => ['so_rcvbuf' => 0]]);
try {
@stream_socket_client("tcp://127.0.0.1:1", $errno, $errstr, 1,
STREAM_CLIENT_CONNECT, $context);
} catch (Throwable $e) {
echo $e::class, ': ', $e->getMessage(), "\n";
}

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

sure once I get a review I ll do all in one swoop.

Comment thread main/streams/xp_socket.c Outdated
Comment thread main/streams/xp_socket.c Outdated
They set SO_RCVBUF and SO_SNDBUF in bytes on TCP and UDP sockets, applied
before connect() and listen(). Values outside 1 to INT_MAX throw a ValueError.

@bukka bukka left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It looks good now!

@devnexen devnexen closed this in 203e59e Sep 5, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants