title: Handling a Biometric Fingerprint Attendance Device by using socket
body: <p>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!)</p>
  
  <p>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 <code>Socket</code> object (through Ethernet port) but also not executed with me. This open infinite loop problems on my head.</p>
  
  <ul>
  <li>Is there any general, standard way to connect, send and retrieve data from such device using Java?</li>
  <li>Can a <code>Socket</code> be considered as a solution for such problem? </li>
  <li>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? </li>
  </ul>
  
  <p>The Socket code that used:</p>
  
  <pre><code>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();
  }
  }
  </code></pre>
  
  <p>This image may give more details: </p>
  
  <p><img src="https://i.stack.imgur.com/hj74q.jpg" alt=""></p>