为了与生物识别设备(ZKTeco K20)进行交互,我正在使用a library from github。现在,问题是我陷入了下面给出的connect()函数中:
public function connect($ip = null, $port = 4370)
{
if($ip != null)
{
$this->ip = $ip;
}
if($port != null)
{
$this->port = $port;
}
if($this->ip == null || $this->port == null)
{
return false;
}
$command = CMD_CONNECT;
$command_string = '';
$chksum = 0;
$session_id = 0;
$reply_id = -1 + USHRT_MAX;
$buf = $this->createHeader($command, $chksum, $session_id, $reply_id, $command_string);
socket_sendto($this->socket, $buf, strlen($buf), 0, $this->ip, $this->port);
try
{
//Attention !!! here is the socket recve function that providing nothring in $this->received_data
socket_recvfrom($this->socket, $this->received_data, 1024, 0, $this->ip, $this->port);
if(strlen($this->received_data)>0)//here getting zero legth data
{
$u = unpack('H2h1/H2h2/H2h3/H2h4/H2h5/H2h6', substr($this->received_data, 0, 8));
$this->session_id = hexdec($u['h6'].$u['h5']);
return $this->checkValid($this->received_data);
}
else
{
return FALSE;
}
}
catch(ErrorException $e)
{
return FALSE;
}
catch(exception $e)
{
return FALSE;
}
}
socket_recvfrom 功能完全不提供任何数据。 $ this-> received_data的长度为零。我检查了我的IP地址和端口是否正确,这在另一个应用程序(设备供应商提供的内置应用程序)中连接正常。实际上,它没有提供任何错误,所以我无法找到问题。我怎么知道?
我也有try another library用于生物识别机器的交互。它也有同样的问题,我没有从 socket_recvfrom 接收数据。