eldoc Posted April 14, 2008 Share Posted April 14, 2008 Hi guys This code (below) worked fine on my website (I have taken out all of the extraneous stuff) until a month ago. It also worked on my local EasyPHP server and still does. My guess is that either [1] an update to php no longer allows it to work (seems very unlikely!) [2] the server has changed its settings in some way Any ideas please. It has always produced a few lines of data (still does on local server) but now just runs - there are no errors just $str is blank instead of full of data. Cheers Eldoc <? $fp = fsockopen("udp://195.149.21.12", 21000, $errno, $errstr,2); stream_set_timeout($fp,1); if (fwrite($fp,"\\status\\") === false){ die(); } $str = fread($fp, 65000); $str = $str.fread($fp, 65000); fclose($fp); echo "<br>".$str."<br>"; ?> Quote Link to comment Share on other sites More sharing options...
Cep Posted April 14, 2008 Share Posted April 14, 2008 Are you able to open a connection via something else to that UDP location? Quote Link to comment Share on other sites More sharing options...
trq Posted April 14, 2008 Share Posted April 14, 2008 Id'e start by replacing <? with the full <?php tags. You might also wrap your call to fsockopen in some error handling. <?php if ($fp = fsockopen("udp://195.149.21.12", 21000, $errno, $errstr,2)) { stream_set_timeout($fp,1); if (fwrite($fp,"\\status\\") === false){ die(); } $str = fread($fp, 65000); $str = $str.fread($fp, 65000); fclose($fp); echo $str; } else { echo $errstr; } ?> Quote Link to comment Share on other sites More sharing options...
eldoc Posted April 14, 2008 Author Share Posted April 14, 2008 Thanks for the prompt reply guys :- [1] yes, I can still connect with the same programme from my local server and used to be able to connect from my site until a month ago [2] it's the same with <?php [3] as stated I have taken out all of the error checking and other stuff to make it as easy to follow as possible. $fp comes back with a handle and no errors. Many thanks Eldoc Quote Link to comment Share on other sites More sharing options...
eldoc Posted April 14, 2008 Author Share Posted April 14, 2008 "bump" Quote Link to comment Share on other sites More sharing options...
eldoc Posted April 14, 2008 Author Share Posted April 14, 2008 "bump" Quote Link to comment Share on other sites More sharing options...
Cep Posted April 15, 2008 Share Posted April 15, 2008 change this bit, if (fwrite($fp,"\\status\\") === false){ die(); } to if (fwrite($fp,"\\status\\") === false){ die("I am dead"); } What happens? Quote Link to comment Share on other sites More sharing options...
eldoc Posted April 15, 2008 Author Share Posted April 15, 2008 No change Cep - still no data. Cheers eldoc Quote Link to comment Share on other sites More sharing options...
Cep Posted April 15, 2008 Share Posted April 15, 2008 I think the underlying problem is your web host then or the address your trying to access. Something has changed there and it sounds like an authentication issue. Perhaps the udp your trying to access has an allow list with certain server IPs, your webhost has changed its IP and is no longer allowed. That is where I would start looking, I doubt this is a PHP issue. Quote Link to comment Share on other sites More sharing options...
btherl Posted April 15, 2008 Share Posted April 15, 2008 UDP connections will always come back with a handle, even if the destination is inaccessible. All that you'll see is that no data comes back. That's just the way it is unfortunately. If your webhost started blocking that udp port, then the behaviour you see would be consistent with that. Quote Link to comment Share on other sites More sharing options...
DyslexicDog Posted April 15, 2008 Share Posted April 15, 2008 Sounds like your webhost started locking things down at the firewall. Quote Link to comment Share on other sites More sharing options...
eldoc Posted April 15, 2008 Author Share Posted April 15, 2008 Many thanks guys - that was what I suspected - my ISP claims nothing has changed - the server I am getting data from has definitely not changed because I have full rights there and can check anything. I will mark this as 'SOLVED' to save anyone wasting more time on it. Thanks to all for taking the time to offer ideas. Cheers Eldoc Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.