rtownsend
rtownsend

Reputation: 1

Simulate offline or down website

i'm writing code in PHP to check if a website (or webserver) is down or not. I have a list of IP addresses to check, then foreach IP address, try to connect to it with fsockopen function on port 53 and if it does then set a variable to the host name of that IP address and break out of the foreach loop. So basically find the first website that it can connect to and save that for reference later.

What i'm trying to do is simulate the first website in the list being down so that it will go to the second website in the list. I have tried adding a rule to block the IP address in Windows firewall inbound and outbound connection and was able to block pinging on the command line and I have tried blocking the port but when I run the PHP code, the fsockopen is still able to connect to the first website..

Are there any other ideas on simulating an offline website or server such that fsockopen wont be able to connect to it without actually shutting the server or website off? or ways to trick my computer into thinking that the website is down such that the fsockopen function wont be able to connect to it? Are there any other ways to test connection to a server in php other than ping and fsockopen?

Any help would be appreciated.

Thank You!

Upvotes: 0

Views: 555

Answers (1)

Peter
Peter

Reputation: 630

If all you need to do is to simulate if an ip/website is offline/down. Use a website/ip that is down or does not exist as the first item on the list.

Another option is to just add logic to the code to return that the website is down regardless if it is or not.

Upvotes: 0

Related Questions