fwrite()不允许,但是phpinfo()表示应该 [英] fwrite() not permitted, but phpinfo() says it should be

查看:144
本文介绍了fwrite()不允许,但是phpinfo()表示应该的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我从尝试运行的脚本中获取以下信息:

I am getting the following from a script I am trying to run:

Notice: fwrite() [function.fwrite]: send of 7 bytes failed with errno=1 Operation not permitted in /home/thrawn/public_html/sorcero.us/MinecraftQuery.class.php on line 165

但是,当我检查phpinfo()时,allow_url_fopen打开,并且启用了套接字支持.我一直找不到任何指向我的原因,这可能是造成这种情况的原因.

However, when I check phpinfo(), allow_url_fopen is on and Sockets Support is Enabled. I haven't been able to find anything pointing me to what might be causing this.

为澄清起见,我没有编写此脚本.我对PHP的了解大多只是基础知识,但是我知道足够多的理由认为这应该可行,因为phpinfo()表示允许正确的操作.有问题的脚本在这里: https://github. com/xPaw/PHP-Minecraft-Query/blob/master/MinecraftQuery.class.php

For clarification, I did not write this script. My knowledge of PHP is mostly just the basics, but I know enough to reason that this should be working since phpinfo() says the correct things are permitted. The script in question is here: https://github.com/xPaw/PHP-Minecraft-Query/blob/master/MinecraftQuery.class.php

推荐答案

fwrite()写入$this->socket并且位于private function WriteData()中.在public function Connect()中是一行

fwrite() writes to $this->socket and is in private function WriteData(). In public function Connect() is a line

$this->Socket = @FSockOpen( 'udp://' . $Ip, (int)$Port, $ErrNo, $ErrStr, $Timeout );

这是文件中唯一写入$this->socket的行.

This is the only line in this file where $this->socket is written.

此外,在 fsockopen() 的联机帮助页中有一条警告消息

Also, there is a warning message in the manpage for fsockopen()

UDP套接字有时似乎已打开且没有错误, 即使远程主机不可访问.错误只会变成 当您向套接字读取数据或从套接字写入数据时很明显.原因 因为这是因为UDP是无连接"协议,这意味着 操作系统不会尝试为该链接建立链接 直到真正需要发送或接收数据为止.

UDP sockets will sometimes appear to have opened without an error, even if the remote host is unreachable. The error will only become apparent when you read or write data to/from the socket. The reason for this is because UDP is a "connectionless" protocol, which means that the operating system does not try to establish a link for the socket until it actually needs to send or receive data.

可能是这种情况.尽管无法找到ip地址或端口,但仍创建了套接字.尝试写入数据时,这会导致错误消息.

This is probably the case. The socket is created although the ip adddress or the port is not reachable. This results in an error message when trying to write data.

因此,要解决此问题,您至少需要执行以下操作:

So in order to resolve this, you would need to do at least these things:

  • 确保IP地址和端口正确.
  • 验证服务器已启动并正在运行.
  • 确保IP地址和端口可访问(在任何防火墙中均未阻止)

我不知道正确的设置应该是什么.如果您已在外部服务器上安装了该软件,也请尝试在本地计算机上使用,以便有一种方法来验证IP地址和端口设置.

I do not know what the correct settings should be. If you have installed the software on an external server, also try your local computer so you have a way to verify the ip address and port settings.

这篇关于fwrite()不允许,但是phpinfo()表示应该的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆