本文整理汇总了PHP中FSockOpen函数的典型用法代码示例。如果您正苦于以下问题:PHP FSockOpen函数的具体用法?PHP FSockOpen怎么用?PHP FSockOpen使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了FSockOpen函数的12个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: Open
public function Open()
{
if (!$this->RconSocket) {
$this->RconSocket = @FSockOpen($this->Socket->Address, $this->Socket->Port, $ErrNo, $ErrStr, $this->Socket->Timeout);
if ($ErrNo || !$this->RconSocket) {
throw new SocketException('Can\'t connect to RCON server: ' . $ErrStr, SocketException::CONNECTION_FAILED);
}
Stream_Set_Timeout($this->RconSocket, $this->Socket->Timeout);
Stream_Set_Blocking($this->RconSocket, true);
}
}
示例2: Open
public function Open()
{
if (!$this->RconSocket) {
$this->RconSocket = @FSockOpen($this->Socket->Ip, $this->Socket->Port, $ErrNo, $ErrStr, $this->Socket->Timeout);
if ($ErrNo || !$this->RconSocket) {
throw new TimeoutException('Can\'t connect to RCON server: ' . $ErrStr, TimeoutException::TIMEOUT_CONNECT);
}
Stream_Set_Timeout($this->RconSocket, $this->Socket->Timeout);
Stream_Set_Blocking($this->RconSocket, true);
}
}
示例3: Open
public function Open()
{
if (!$this->RconSocket && $this->Socket->Engine == CI_SourceQuery::SOURCE) {
$this->RconSocket = @FSockOpen($this->Socket->Ip, $this->Socket->Port, $ErrNo, $ErrStr, $this->Socket->Timeout);
if ($ErrNo || !$this->RconSocket) {
throw new SourceQueryException('Can\'t connect to RCON server: ' . $ErrStr);
}
Stream_Set_Timeout($this->RconSocket, $this->Socket->Timeout);
Stream_Set_Blocking($this->RconSocket, true);
}
}
示例4: Connect
public function Connect($Ip, $Port = 25575, $Password, $Timeout = 3)
{
$this->RequestId = 0;
if ($this->Socket = FSockOpen($Ip, (int) $Port)) {
Socket_Set_TimeOut($this->Socket, $Timeout);
if (!$this->Auth($Password)) {
$this->Disconnect();
} else {
return true;
}
}
}
示例5: Connect
public function Connect($Ip, $Port = 25575, $Password, $Timeout = 3)
{
$this->RequestId = 0;
if ($this->Socket = @FSockOpen($Ip, (int) $Port)) {
Socket_Set_TimeOut($this->Socket, $Timeout);
if (!$this->Auth($Password)) {
$this->Disconnect();
throw new MinecraftRconException("Authorization failed, password is wrong.");
}
} else {
throw new MinecraftRconException("Can`t connect to MC server.");
}
}
示例6: Connect
public function Connect($Ip, $Port = 25575, $Password, $Timeout = 3)
{
$this->RequestId = 0;
if ($this->Socket = @FSockOpen($Ip, (int) $Port, $errno, $errstr, $Timeout)) {
Socket_Set_TimeOut($this->Socket, $Timeout);
if (!$this->Auth($Password)) {
$this->Disconnect();
throw new MinecraftRconException("Authorization failed.");
}
} else {
throw new MinecraftRconException("Server offline");
}
}
示例7: Connect
public function Connect($Ip, $Port = 25575, $Password, $Timeout = 3)
{
$this->RequestId = 0;
if ($this->Socket == FSockOpen($Ip, (int) $Port)) {
Socket_Set_TimeOut($this->Socket, $Timeout);
if (!$this->Auth($Password)) {
$this->Disconnect();
throw new MinecraftRconException("Неудалось авторизироваться.");
}
} else {
throw new MinecraftRconException("Сервер недоступен.");
}
}
示例8: Connect
public function Connect($Ip, $Port = 25575, $Password, $Timeout = 3)
{
$this->RequestId = 0;
if ($this->Socket = FSockOpen($Ip, (int) $Port)) {
Socket_Set_TimeOut($this->Socket, $Timeout);
if (!$this->Auth($Password)) {
$this->Disconnect();
throw new MinecraftRconException("Authorization failed.");
}
} else {
throw new MinecraftQueryException("Can't open socket.");
}
}
示例9: Open
public function Open($Address, $Port, $Timeout, $Engine)
{
$this->Timeout = $Timeout;
$this->Engine = $Engine;
$this->Port = $Port;
$this->Address = $Address;
$this->Socket = @FSockOpen('udp://' . $Address, $Port, $ErrNo, $ErrStr, $Timeout);
if ($ErrNo || $this->Socket === false) {
throw new SocketException('Could not create socket: ' . $ErrStr, SocketException::COULD_NOT_CREATE_SOCKET);
}
Stream_Set_Timeout($this->Socket, $Timeout);
Stream_Set_Blocking($this->Socket, true);
}
示例10: Open
public function Open($Ip, $Port, $Timeout, $Engine)
{
$this->Timeout = $Timeout;
$this->Engine = $Engine;
$this->Port = $Port;
$this->Ip = $Ip;
$this->Socket = @FSockOpen('udp://' . $Ip, $Port, $ErrNo, $ErrStr, $Timeout);
if ($ErrNo || $this->Socket === false) {
throw new Exception('Could not create socket: ' . $ErrStr);
}
Stream_Set_Timeout($this->Socket, $Timeout);
Stream_Set_Blocking($this->Socket, true);
return true;
}
示例11: Connect
public function Connect($Ip, $Port = 25565, $Timeout = 3)
{
if ($this->Socket = FSockOpen('udp://' . $Ip, (int) $Port)) {
Socket_Set_TimeOut($this->Socket, $Timeout);
$Challenge = $this->GetChallenge();
if ($Challenge === false) {
FClose($this->Socket);
return false;
}
if (!$this->GetStatus($Challenge)) {
FClose($this->Socket);
return false;
}
FClose($this->Socket);
return true;
} else {
return false;
}
}
示例12: Connect
public function Connect($Ip, $Port = 25565, $Timeout = 3)
{
if (!is_int($Timeout) || $Timeout < 0) {
throw new InvalidArgumentException('Timeout must be an integer.');
}
$this->Socket = @FSockOpen('udp://' . $Ip, (int) $Port, $ErrNo, $ErrStr, $Timeout);
if ($ErrNo || $this->Socket === false) {
throw new MinecraftQueryException('Could not create socket: ' . $ErrStr);
}
Stream_Set_Timeout($this->Socket, $Timeout);
Stream_Set_Blocking($this->Socket, true);
try {
$Challenge = $this->GetChallenge();
$this->GetStatus($Challenge);
} catch (MinecraftQueryException $e) {
FClose($this->Socket);
throw new MinecraftQueryException($e->getMessage());
}
FClose($this->Socket);
}