连接服务器
resource Module_Storage_Driver_Swift::fp( string $protocol , int $host , int $port , $timeout )
参数列表
参数 类型 描述 默认值 $protocol
string
$host $host
int
$port $port
int
$timeout $timeout
unknown
resource
fsockopen returns a file pointer which may be usedprotected function fp($protocol, $host, $port , $timeout)
{
try
{
if ($protocol == 'https')
{
$fp = fsockopen('tls://' . $host, $port, $errno, $errstr, $timeout);
}
else
{
$fp = fsockopen($host, $port, $errno, $errstr, $timeout);
}
}
catch (Exception $e)
{
$errstr = $e->getMessage();
$errno = $e->getCode();
$fp = false;
}
if (!$fp)
{
throw new Exception('Unable to connect to: ' . $host . ':' . $port ."\nError: " . $errstr . ' : ' .$errno);
}
return $fp;
}