Php, most portable remote server connection with core streams?
<p>To have cURL support, then php must be compiled --with-curl option.<br />
To have sockets support, then php must be compiled with --enable-sockets option.<br />
To have stream wrappers support for http, ftp ... in functions like fopen, file_get_contents ... then allow_url_fopen must be set to On in php.ini.<br /><br />
While most shared webhosting servers have all (or almost all) previous features enabled, some of them<br /> may not have support for those features, because their optional status.<br />
<br />
On the other hand streams are part of php core.<br />
If somebody wants to make a verry portable(i think) php http client for example, not based on cURL,
socket, or wrappers(http) support, then, that can be done with:<br /></p>

<pre><code>$fp = stream_socket_client("tcp://example.com:80", $errno, $errstr);
fwrite($fp, "GET / HTTP/1.0\r\nHost: example.com\r\nAccept: */*\r\n\r\n");
</code></pre>

<p>using not a http stream wrapper but a stream transport wrapper(tcp) which is different.<br /><br />
I saw on my localhost that even when php.ini directive allow_url_fopen is set to Off,
I can make remote connection via stream_socket_client() using tcp transport.<br /><br />
My questions are:<br />
1. Is there a way to block availability of core streams, except the possibility to disable functions like stream_socket_client or fsockopen in php.ini by  hardcoding them like:</p>

<pre><code>disable_functions = exec,passthru,shell_exec,stream_socket_client,fsockopen ...
</code></pre>

<p>???<br />
2. Is  the use of <code>$fp = stream_socket_client('tcp://...',[...]);</code> the most portable solution
for making remote connections, that can be turned later in http/ftp... requests by connecting first to the right port(e.g 80) and using <code>fwrite($fp, 'GET /...');</code> to send low level http/ftp queries
to the remote server?</p>
