What are the advantages of using stream_socket_* functions over cURL for network communication in PHP?

Using stream_socket_* functions in PHP for network communication can offer better performance and more control compared to cURL. This is especially useful when dealing with low-level socket operations or when needing to customize the connection parameters. Additionally, stream_socket_* functions allow for more flexibility in handling different protocols and data formats.

// Example code demonstrating the use of stream_socket_* functions for network communication
$socket = stream_socket_client('tcp://www.example.com:80', $errno, $errstr, 30);
if (!$socket) {
    echo "Error: $errstr ($errno)\n";
} else {
    fwrite($socket, "GET / HTTP/1.1\r\nHost: www.example.com\r\nConnection: close\r\n\r\n");
    while (!feof($socket)) {
        echo fgets($socket, 1024);
    }
    fclose($socket);
}