PHP TCP客户端无法连接到服务器

PHP TCP客户端无法连接到服务器,php,tcp,client,Php,Tcp,Client,我收集了一些将TCP客户端连接到服务器并更改IP的示例,但我不知道代码中的错误是什么,因为它应该可以工作,并且服务器也可以从Gta San Andrease多人脚本控制台联机,服务器位于另一台pc的本地主机上,ip为192.168.0.11,服务器端口为7777,以下是我的PHP网站上的客户端代码: <?php // form submitted // where is the socket server? $host="192.168.0.11"; $port = 7

我收集了一些将TCP客户端连接到服务器并更改IP的示例,但我不知道代码中的错误是什么,因为它应该可以工作,并且服务器也可以从Gta San Andrease多人脚本控制台联机,服务器位于另一台pc的本地主机上,ip为192.168.0.11,服务器端口为7777,以下是我的PHP网站上的客户端代码:

 <?php

  // form submitted
  // where is the socket server?
  $host="192.168.0.11";
  $port = 7777;
  // open a client connection
  echo "1";
  $fp = fsockopen ($host, $port, $errno, $timeout);
  echo "2";
  if (!$fp){
  echo "3";
  $result = "Error: could not open socket connection";
  }
  else
  {
 echo "4";
  // get the welcome message
  fgets ($fp, 7777);
  // write the user string to the socket
  fputs ($fp, $message);
  // get the result
  $result .= fgets ($fp, 7777);
  // close the connection
  fputs ($fp, "END");
  fclose ($fp);
  // trim the result and remove the starting ?
  $result = trim($result);
  $result = substr($result, 2);
  // now print it to the browser
  }
  ?>
  Server said: <b><? echo $result; ?></b>
  <?

  ?>

服务器说:
这是警告/错误:


警告:fsockopen():无法连接到192.168.0.11:7777(连接尝试失败,因为连接方在一段时间后没有正确响应,或者建立的连接失败,因为连接的主机没有响应。)

到底是什么问题?脚本在某一点死亡?不按预期工作?更新了我的问题,请阅读最后一部分内容。这听起来就像是混音中的某个防火墙在无声地丢弃数据包,而不是用重置来响应。我不明白,你想让我关闭防火墙吗?不,但至少要确保两边都允许7777端口通过(您的客户端和服务器上)