PHP 8.5: socket_set_timeout function deprecated in favor of stream_set_timeout

Version8.5
TypeDeprecation

The socket_set_timeout function is an alias to the stream_set_timeout function. It sets the timeout period for the given stream.

The stream_set_timeout, which is the canonical function, was previously called set_socket_timeout, and was renamed to socket_set_timeout later.

In PHP 8.5, the alias function socket_set_timeout is deprecated, and calling it emits a deprecation notice:

stream_set_timeout($server, 0, 1000);
Function socket_set_timeout() is deprecated since 8.5, use stream_set_timeout() instead

Recommended Replacement

To avoid the deprecation notice, replace the socket_set_timeout function call with stream_set_timeout. Because socket_set_timeout is an alias to the stream_set_timeout function, this change is completely backwards compatible and the behavior will be identical.


socket_set_timeout RFC Implementation