I've heard, that in UNIX everything is a file, therefore I'm trying to bind a socket and read it as file.
I've created socket in PHP and I had bound it to file, in directory I know I have permissions to. I can't read it using cat
$socket = socket_create(AF_UNIX, SOCK_STREAM, 0);
socket_bind($socket, "/home/me/socket");
socket_listen($socket);
$client = socket_accept($socket);
socket_set_nonblock($client);
$buffer = socket_read($client, 2048);
echo $buffer;
socket_close($client);
socket_close($socket);
> cat /home/me/socket
cat: /home/me/socket: No such device or address
I've expected that I just create socket, and then I can read it, in current state I would expect it to read out as empty. Not having "unexisting adress" because when I try to bind socket there, it's occupied, but cat doesn't read it.
So question is how to "adjust" socket, so it turns out as file when attempting to be read, like normal unix component.