PHP - fsockopen()连接超时

时间:2011-12-12 00:35:45

标签: java php minecraft

  

可能重复:
  PHP and HTML: socket_connect() [function.socket-connect]: unable to connect

我使用PHP连接到运行Java .jar的服务器。我安装了一个插件,允许从外部PHP文件连接。我不断得到连接超时错误。昨晚工作正常,不知道发生了什么变化。端口4445被转发,我可以通过telnet连接到它,我在我的服务器的防火墙中允许我的网站的IP。

您可以在此处查看PHP代码: http://pastebin.com/PLAfApdT

<?php
 $HOST = "207.210.254.141"; //the ip of the bukkit server
 $password = "examplepassword1";
 $player = $_POST["fname"];
 if (empty($player)) {
     sleep(0);
     printf("<script language = 'javascript'>history.go(-1)</script>");}
 else {
 //Can't touch this:
 fsockopen($HOST, 4445)
 or die("error: could not connect to host\n");
 //Authentification
 fwrite($command = md5($password)."<Password>", strlen($command) + 1)
 or die("error: failed to write to socket\n");
 //Begin custom code here.
 fwrite($command = "/Command/ExecuteConsoleCommand:give $player 264 5;", strlen($command) + 1)
 or die("error: failed to write to socket\n");
 fwrite($command = "/Command/ExecuteConsoleCommand:say $player voted for MOOcraft and earned 5 diamonds. Vote at moocraft.org;", strlen($command) + 1)
 or die("error: failed to write to socket\n");
 echo "Thanks for Voting! You can vote again in 24 hours and recieve more diamonds!";}
?>

0 个答案:

没有答案