I am trying to make an API to read from attendance machine. I find the port from which it is communicating and made successfull connection to it by Java Socket Programming. Now I am trying to get data from it but don't know how to do it. I tried buffered reader and input stream method and redline() but still it does not read anything and then gives errors as connection reset.
Here is my code... If anyone can help.
<%@page import="java.net.*"%>
<%@page import="java.io.*"%>
<%
String host = "IP of Machine";
int port = Integer.parseInt("Port from it is communicating");
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.toString());
}
}
} catch (UnknownHostException e) {
e.printStackTrace();
} catch (IOException e) {
e.printStackTrace();
}
%>
I checked some other SDKs and found that it reads from general log of machine, but i am not able to find log or don't know where to find the log.