Error on my website "connection refused"

hi there so i also have the website tyriancraft.com
however the server status widget wont load the server stats…
it comes up with connection refused or timed out on line 39

line 39 is…

$header = stream_socket_client(‘tcp://’.$this->host.’:’.$this->port, $errno, $errstr, 1)

please help as i have no idea where to go from here!

Matt

you are only allowing 1 second, try changing it to 30.
[php]$header = stream_socket_client(‘tcp://’.$this->host.’:’.$this->port, $errno, $errstr, 30);[/php]

and don’t forget the semi-colon at the end. (missing from your OP).

Red :wink:

hey thanks for the help but its still wont connect! <?php
[php]/**
*

  • @Třída serveru
    */

class Server
{

public $host;
public $port;

public function __construct($host, $port = 25565)
{
$this->port = (int)($port);

if(preg_match('/:\d+$/', $host)) {
		
		if(preg_match('/:\/\//', $host))
  {
			list($protocol, $this->host, $this->port) = explode(':', str_replace('//', '', $host));
		}
  else
  {
			list($this->host, $this->port) = explode(':', $host);
		}
		
	}
else
{
		$this->host = $host;
	}

}


public function info()

{
$header = stream_socket_client(‘tcp://’.$this->host.’:’.$this->port, $errno, $errstr, 45);

	$stats = array(
  'online'=>false,
  'version'=>false,
  'players'=>false,
  'max'=>false,
);
	
	if (!$header)
		return $stats;

	fwrite($header, "\xfe\x01");
	$info = fread($header, 1024);
	fclose($header);

	if(!$info) 
		return $stats;

	$info = substr($info, 9);
	$info = mb_convert_encoding($info, 'auto', 'UCS-2');
	$info = explode("\x00", $info);

	$stats['online'] = true;
	list($stats['protocol'], $stats['version'], $stats['name'], $stats['players'], $stats['max']) = $info;

	return $stats;

}

}
[/php]
thats the entire code,
it still just says connection refused, the website is tyriancraft.com and its for a minecraft server, any help would be appreciated :smiley:

Sponsor our Newsletter | Privacy Policy | Terms of Service