Converting PHP strings to binary format and reconverting them when connecting to server
<p>I'm looking to code a php script that would connect to a server using binary protocol, send queries and receive data from it. I wondered how I can implement this in php? So far I have:</p>

<pre><code>&lt;?php
$fp = fsockopen("111.111.10.10", "2222", $errno, $errstr, 10);
if (!$fp) {
    echo "$errstr ($errno)&lt;br /&gt;\n";
} else {
    fwrite($fp, "You message");
    while (!feof($fp)) {
        echo fgets($fp, 128);
    }
    fclose($fp);
}
?&gt;
</code></pre>

<p>When I speak of binary, I don't mean the underlying of computer language, I mean that the specific string that is sent to the server should be converted in "0101001", since that is the way server reads and converts info. I need a way to convert php strings to this format and reconvert them back.</p>

<p>I will explain if you don't fully understand the question.</p>
