PHP Conference Nagoya 2025

socket_recvmsg

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

socket_recvmsgRead a message

Description

socket_recvmsg(Socket $socket, array &$message, int $flags = 0): int|false

Warning

This function is currently not documented; only its argument list is available.

Parameters

socket

message

flags

Return Values

Changelog

Version Description
8.0.0 socket is a Socket instance now; previously, it was a resource.

See Also

add a note

User Contributed Notes 1 note

up
-4
251701981 at qq dot com
1 year ago
$sockets = [];
\socket_create_pair(AF_UNIX,SOCK_DGRAM,0,$sockets);

$proc = new \Swoole\Process(function()use($sockets){

socket_close($sockets[0]);

$f = fopen(__FILE__,'r');
var_dump($f);
socket_sendmsg($sockets[1],[ 'control'=>[['level'=>SOL_SOCKET,'type'=>SCM_RIGHTS,'data'=>[$f]] ] ],0);
sleep(10);

},false,2,1);

$proc->start();

socket_close($sockets[1]);

$data = [
'controllen'=>socket_cmsg_space(SOL_SOCKET,SCM_RIGHTS,1)
];

socket_recvmsg($sockets[0],$data,0);

var_dump($data);

sleep(10);
To Top