Java 使用socket处理生物指纹考勤机

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/23990924/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-14 09:35:46  来源:igfitidea点击:

Handling a Biometric Fingerprint Attendance Device by using socket

javasocketsnetwork-programmingfingerprintbiometrics

提问by Maheera Jazi

I am trying to connect with a Biometric Fingerprint Attendance Device using a Java program. The device I am using is a Biocom Fingerprint attendance system. However, I am search and reading about that and I see the SDK could used which based on device type (which hard, not logical, moreover, it is not global solution!)

我正在尝试使用 Java 程序连接生物指纹考勤设备。我使用的设备是 Biocom 指纹考勤系统。但是,我正在搜索和阅读有关此内容的内容,我看到可以根据设备类型使用 SDK(这很难,不合逻辑,而且,它不是全局解决方案!)

I research for a global standard on how to connect, send and retrieve data with a Fingerprint Device which again I wasn't lucky enough to find a clear solution. Currently, I tried to connect with the device by creating a Socketobject (through Ethernet port) but also not executed with me. This open infinite loop problems on my head.

我正在研究如何使用指纹设备连接、发送和检索数据的全球标准,但我再次没有足够幸运地找到明确的解决方案。目前,我试图通过创建一个Socket对象(通过以太网端口)来连接设备,但也没有与我一起执行。这个开放的无限循环问题在我头上。

  • Is there any general, standard way to connect, send and retrieve data from such device using Java?
  • Can a Socketbe considered as a solution for such problem?
  • If yes, what is wrong in my code below? What additional things more than the host IP and port number are needed to connect with the device?
  • 是否有任何通用的标准方法可以使用 Java 从此类设备连接、发送和检索数据?
  • 可以将 aSocket视为此类问题的解决方案吗?
  • 如果是,我下面的代码有什么问题?除了主机 IP 和端口号之外,还需要哪些其他东西才能与设备连接?

The Socket code that used:

使用的 Socket 代码:

import java.io.IOException;
import java.io.ObjectInputStream;
import java.io.ObjectOutputStream;
import java.net.Socket;
import java.net.UnknownHostException;

public class Requester {
Socket requestSocket;
ObjectOutputStream out;
ObjectInputStream in;
String message;

Requester() {
}

void run() throws IOException {
    try {
        // 1. creating a socket to connect to the server
        requestSocket = new Socket("192.168.0.19", 4370);
        System.out.println("Connected to given host in port 4370");
        // 2. get Input and Output streams
        in = new ObjectInputStream(requestSocket.getInputStream());
        // 3: Communicating with the server
        String line;
        while (true) {
            line = in.readLine();
            if (line != null) {
                System.out.println(line);
            }
        }
    } catch (UnknownHostException unknownHost) {
        System.err.println("You are trying to connect to an unknown host!");

    } catch (IOException ioException) {
        ioException.printStackTrace();

    } catch (Exception Exception) {
        Exception.printStackTrace();

    } finally {
        in.close();
        requestSocket.close();
    }
}

void sendMessage(String msg) {
    try {
        out.writeObject(msg);
        out.flush();
        System.out.println("client: " + msg);

    } catch (IOException ioException) {
        ioException.printStackTrace();
    }
}

public static void main(String args[]) throws IOException {
    Requester client = new Requester();
    client.run();
}
}

This image may give more details:

此图像可能会提供更多详细信息:

回答by BetaRide

You don't need the ObjectInputStream. Just use the InputStreamyou get from requestSocket.getInputStream().

你不需要ObjectInputStream. 只需使用InputStream您从requestSocket.getInputStream().

Alternatively use a terminal programm like putty to connect to your device. This requires no coding.

或者使用像 putty 这样的终端程序连接到您的设备。这不需要编码。

回答by Ramshri

Biocom Biometrics are ZKTeco devices. ZkTeco devices are launched only with windows SDK. You can download the SDK from https://www.zkteco.com/en/download_catgory.htmland use the DLL in java which can run only on Windows platorm. For HTTP communication, to work in any platform through any language, refer http://camsunit.com/application/zk-teco-essl-api-integration.html

Biocom Biometrics 是 ZKTeco 设备。ZkTeco 设备仅使用 Windows SDK 启动。您可以从https://www.zkteco.com/en/download_catgory.html下载 SDK并使用只能在 Windows 平台上运行的 java 中的 DLL。对于 HTTP 通信,要通过任何语言在任何平台上工作,请参阅http://camsunit.com/application/zk-teco-essl-api-integration.html