Overview
KB
Technical FAQ
PHP Manual
CSS2 Manual
HTML Manual
JS Guide
JS Reference
PhpDock Manual
Nu-Coder Manual
PhpExpress Manual
PHP Joomla
Development
Learn PHP
 
<socket_getsocknamesocket_last_error>
^Socket FunctionsLast updated: Mon, 26 Oct 2026

socket_import_stream

(PHP 5 >= 5.4.0, PHP 7, PHP 8)

socket_import_stream — Import a stream

Description

function socket_import_stream(resource $stream): Socket|false

Imports a stream that encapsulates a socket into a socket extension resource.

Parameters

stream

The stream resource to import.

Return Values

Returns false on failure.

Changelog

Version Description
8.0.0 On success, this function returns a Socket instance now; previously, a resource was returned.

Examples

Example #1 socket_import_stream() example

<?php
$stream = stream_socket_server("udp://0.0.0.0:58380", $errno, $errstr, STREAM_SERVER_BIND); 
$sock   = socket_import_stream($stream);
?>

See Also


<socket_getsocknamesocket_last_error>
^Socket FunctionsLast updated: Mon, 26 Oct 2026