douhei8633 2016-07-07 17:13
浏览 61

离线或下载网站模拟

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!

  • 写回答

1条回答 默认 最新

  • dtwd74916 2016-07-07 19:23
    关注

    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.

    评论

报告相同问题?

悬赏问题

  • ¥20 数学建模,尽量用matlab回答,论文格式
  • ¥15 昨天挂载了一下u盘,然后拔了
  • ¥30 win from 窗口最大最小化,控件放大缩小,闪烁问题
  • ¥20 易康econgnition精度验证
  • ¥15 msix packaging tool打包问题
  • ¥28 微信小程序开发页面布局没问题,真机调试的时候页面布局就乱了
  • ¥15 python的qt5界面
  • ¥15 无线电能传输系统MATLAB仿真问题
  • ¥50 如何用脚本实现输入法的热键设置
  • ¥20 我想使用一些网络协议或者部分协议也行,主要想实现类似于traceroute的一定步长内的路由拓扑功能