Snoopy::_connect()publicWP 1.0

Method of the class: Snoopy{}

No Hooks.

Return

null. Nothing (null).

Usage

$Snoopy = new Snoopy();
$Snoopy->_connect( $fp );
$fp (required) (passed by reference — &)
-

Snoopy::_connect() code WP 6.4.3

function _connect(&$fp)
{
	if(!empty($this->proxy_host) && !empty($this->proxy_port))
		{
			$this->_isproxy = true;

			$host = $this->proxy_host;
			$port = $this->proxy_port;
		}
	else
	{
		$host = $this->host;
		$port = $this->port;
	}

	$this->status = 0;

	if($fp = fsockopen(
				$host,
				$port,
				$errno,
				$errstr,
				$this->_fp_timeout
				))
	{
		// socket connection succeeded

		return true;
	}
	else
	{
		// socket connection failed
		$this->status = $errno;
		switch($errno)
		{
			case -3:
				$this->error="socket creation failed (-3)";
			case -4:
				$this->error="dns lookup failure (-4)";
			case -5:
				$this->error="connection refused or timed out (-5)";
			default:
				$this->error="connection failed (".$errno.")";
		}
		return false;
	}
}