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:
<?php
$fp = fsockopen("111.111.10.10", "2222", $errno, $errstr, 10);
if (!$fp) {
echo "$errstr ($errno)<br />
";
} else {
fwrite($fp, "You message");
while (!feof($fp)) {
echo fgets($fp, 128);
}
fclose($fp);
}
?>
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.
I will explain if you don't fully understand the question.