Hello friends, I have written a program which opens up a socket on port 514. This is to accept and save logs from my wireless WAP54G router. I would like to eventually be able to use a buffered reader so I can stream the input into log files locally, but I can't seem to establish a connection. The connection eventually times out, and the program exits. Here is what I have:
import java.io.*; import java.net.*; public class KnockServer { public static void main(String args[]) { KnockServer server = new KnockServer(); server.mainLoop(); } public void mainLoop() { try { ServerSocket server = new ServerSocket(514); server.setSoTimeout(100000); System.out.println("Success!"); while (true) { Socket connection = server.accept(); BufferedInputStream in = new BufferedInputStream(connection.getInputStream()); InputStreamReader inputReader = new InputStreamReader(in); StringBuffer process = new StringBuffer(); connection.close(); server.close(); } } catch (IOException e) { System.out.println("Couldn't!"); System.err.println(e.getMessage()); } catch (SecurityException e) { System.err.println(e.getMessage()); } } }
Things to note: I am running Eclipse on Ubuntu. I am running the program with super user privileges. I have another program that somebody else has written in C, which opens up port 514 that does establish a connection, and I am able to see what the router is sending.
If anybody notices anything wrong with what I have written and could please give me a direction I would appreciate it. Also, if anybody else has any suggestions of what else it could be related to, that would be helpful as well.