سؤال

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

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.

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() 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 is the only line in this file where $this->socket is written.

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

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.

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:

  • Make sure the ip address and port are correct.
  • Verify that the server is up and running.
  • Make sure the ip address and port are reachable (not blocked in any firewalls)

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.

نصائح أخرى

If you checked your PHP configuration and the problem persists, check your firewall log.

As Ignacio Vazquez-Abrams stated: this is an OS error.

In my case, CSF was blocking outgoing connections.

Seems like permission error,

Try,

 chmod -R folder_to_be_file_written

Then execute php script

مرخصة بموجب: CC-BY-SA مع الإسناد
لا تنتمي إلى StackOverflow
scroll top