I am trying to send a .BIN file over a TCP socket using PHP. This is what I have:
$fp = fsockopen("127.0.0.1", 80, $errno, $errstr, 30);
if (!$fp) {
echo "$errstr ($errno)<br />\n";
} else {
fwrite($fp, "You message");
while (!feof($fp)) {
echo fgets($fp, 128);
}
fclose($fp);
}
I am unsure how to send the BIN file, and when testing it, the page just infinitely loops.
Can someone help me? Is there a better way to send a file over TCP using PHP?