Example 1 — Call Shape for Accept
Show the typical accept pattern with comments. A real run needs a listening server and a connecting client.
<?php
// Needs a listening server from stream_socket_server().
// Illustrative output for tutorials (not a live accept):
$peer = '127.0.0.1:54321';
echo 'accepted peer: ', $peer, PHP_EOL;
echo 'next: fread/fwrite on the client stream', PHP_EOL; How It Works
- stream_socket_server() creates the listening socket first.
- stream_socket_accept() waits for one incoming client.
- The peer address looks like host:port.
- Use the returned client stream for fread() and fwrite().

