PHP 和 HTML:socket_connect() [function.socket-connect]:无法连接
问题描述
我正在处理一个连接到我的游戏服务器并执行命令的 php 文件.用户在发送他们的 HTML 表单上输入他们的用户名,并将用户名输入到连接到服务器的 php 文件中.端口已转发,服务器已准备好接收信息,但我不断收到此错误:
警告:socket_connect() [function.socket-connect]:无法连接 [110]:第 8 行/home/moocraft/public_html/test/vote.php 中的连接超时错误:无法连接到主机
这是 HTML 文件:
看看你得到了什么,这可能是由于你的服务器响应时间过长
I am working on a php file that connects to my game server and executes a command. The users enter their username on a HTML form that sends them and the username to a php file that connects to the server. The port is forwarded and the server is ready to receive the info, but I keep getting this error:
Warning: socket_connect() [function.socket-connect]: unable to connect [110]: Connection timed out in /home/moocraft/public_html/test/vote.php on line 8 error: could not connect to host
Here is the HTML file:
Here is the PHP file:
I can't figure out why I keep getting this. Any help is greatly appreciated.
Try something simple like:
$fp = fsockopen("207.210.254.141", 4445, $errno, $errstr, 30); if (!$fp) { echo "$errstr ($errno)
"; } else { $out = "GET / HTTP/1.1 "; $out .= "Host: 207.210.254.141 "; $out .= "Connection: Close "; fwrite($fp, $out); while (!feof($fp)) { echo fgets($fp, 128); } fclose($fp); }
And see what do you get, it might be due to the reason that your server is taking too long to respond
这篇关于PHP 和 HTML:socket_connect() [function.socket-connect]:无法连接的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!