title: Retrieving data from Biometric Fingerprint Attendance Device
body: <p>I am trying to connect with a <strong>Biometric Fingerprint Attendance Device</strong> using a Java Program. The device I am using is a <strong>Pegasus T5</strong> Fingerprint scanner. Unfortunately their SDK for this device (<a href="https://code.google.com/p/pegasusequipments/downloads/detail?name=T5%20Time%20Attendance%2020110909OCX.rar&amp;can=2&amp;q=" rel="noreferrer">which can be downloaded here</a>) covers only C#, .Net, and VB which I have no expertise. And when I have requested the manufacturers, they have replied that there is no <strong>Java SDK</strong> for the device. Even though I have no knowledge on any of those languages, I gave a try to understand the codes in the SDK to find out how the device is connecting and I saw that it is just making a connection with the device using the network ip and port number.</p>
  
  <p>If you refer to the C# SDK of the device, you can see the example I saw on this at 
  <em>frmEvent.cs</em> which in the <code>cmdStartMoniter_Click</code> method, make the connection as follows.</p>
  
  <pre><code>bRet = bpc.StartEventCapture(0, util.pubIPAddrToLong(txtSourceIP.Text), Convert.ToInt32(txtPortNumber.Text));
  </code></pre>
  
  <p>And that refers to the method <code>StartEventCapture</code> as <code>public virtual bool StartEventCapture(int dwCommType, int dwParam1, int dwParam2);</code> which is in a <em>.dll</em> file as it appears and which I have lost my track as I have further knowledge on how to figure out the code.</p>
  
  <p>However keeping that example I had seen in my head, as my next step I started researching 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. But with some examples from some people who have been trying to deal with the same and the example I saw by myself, I tried to connect with the device by creating a <code>Socket</code> object but when I executed it, it only resulted with the <code>java.net.ConnectException: Connection timed out: connect</code></p>
  
  <p>There are four questions</p>
  
  <ol>
  <li>Is there any Java SDK for Biometric Fingerprint Attendance Devices which I can use for my device as well?</li>
  <li>Is there any general, standard way to connect, send and retrieve data from such device using Java?</li>
  <li><strong>If</strong> connecting to the device via a <code>Socket</code> is a solution, is there any specific, standard requests I should be sending to the device in order to receive a response from it?</li>
  <li>If the attempt I have made is a way to do it, what I have I done wrong with it and how should I correct the problem?</li>
  </ol>
  
  <p>This is the code I used to connect with the device.</p>
  
  <pre><code>    String host = "192.168.168.100";
      int port = Integer.parseInt("5005");
  
      try {
          Socket socket = new Socket(host, port);
          BufferedReader in = new BufferedReader(new InputStreamReader(socket.getInputStream()));
  
          String line;
          while (true){
              line = in.readLine();
              if (line != null){
                  System.out.println(line);
              }
          }
      } catch (UnknownHostException e) {
          e.printStackTrace();
      } catch (IOException e) {
          e.printStackTrace();
      }
  </code></pre>