Sending and recieving data from udp
Posted: Wed Sep 23, 2009 3:47 pm
Okay, ive been playing with this all night long, well... for two days now, I am trying to send data, that i have in binary format to a udp port on a server and then recieve the response. This is the basic script i have
i have been playing with different ways to read that data, and well, im not even sure that im capturing it right, its basically straight from the php.net site, but i have been researching and it appears that i am somewhat on the right path. I have found that i cannot just print the $fp data, as i just get "Resource id #1" as its not data but just seems to show me how to get the data. I really am lost, i have tried everything i could research and still get nothing. I fear that im much further off than i think.
Thanks for anything that you may have to help
Code: Select all
<?php
$binary_msg = chr(0x00).chr(0x02).chr(0xF1).chr(0x26).chr(0x01).chr(0x26).chr(0xF0).chr(0x90).chr(0xA6).chr(0xF0).chr(0x26).chr(0x57).chr(0x4E).chr(0xAC).chr(0xA0).chr(0xEC).chr(0xF8).chr(0x68).chr(0xE4).chr(0x8D).chr(0x21);
$fp = fsockopen("udp://<<ipaddresshere>>",2302,$errno,$errstr);
if (!$fp) {
echo "ERROR: $errno - $errstr<br />\n";
} else {
fwrite($fp, $binary_msg);
echo fread($fp, 26);
fclose($fp);
}
?>Thanks for anything that you may have to help