[英]Cant get php script to ping specific port and IP
I have been trying to ping a specific IP and port to check if it online or offline. 我一直在尝试ping特定的IP和端口,以检查它是联机还是脱机。 If I set the port to 80, it works but any other port it says it not working.
如果我将端口设置为80,则可以使用,但是其他任何端口都不能正常使用。 I am able to connect to the port via game, telnet, etc
我可以通过游戏,telnet等连接到端口
//Connection Info
$ip = "*******"; //IP
$port = "2302"; //Port
//Connection
$sock = @fsockopen( $ip, $port, $num, $error, 2 ); //2 is the ping time, you can sub what you need
//Check Status
if( !$sock ){
//Closed
echo( "It appears to be closed" );
}
if( $sock ){
//Open
echo( "It appears to be open" );
fclose($sock);
}
Here is the error I get 这是我得到的错误
Warning: fsockopen() [function.fsockopen]: unable to connect to *******:2302 (No connection could be made because the target machine actively refused it. )
If I set the port to 80, it works but any other port it says it not working.
如果我将端口设置为80,则可以使用,但是其他任何端口都不能正常使用。
This makes it look pretty much like a firewall problem (either on the generating end or at the receiving end). 这使得它看起来很像防火墙问题(在生成端还是在接收端)。
Are you sure the server where this code's running is allowing any communication at all except to a restricted range of ports? 您确定运行此代码的服务器是否允许除限制端口范围外的所有通信 ? How about ports 25, 81, 110, 443 and 8080?
端口25、81、110、443和8080怎么样?
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.