Question

I have been working on a java project that uses a gui to interface a C program over network ports. I am able to connect to the program and send info with a button actionListener event, but is there a generic update method or event handler so I can constantly listen on the port for info to come from the C program? Maybe there is a way to assign an event Handler to the port? Right now I am using:

    out = new PrintStream(myPort.getOutputStream());
    in = new BufferedReader(new InputStreamReader(myPort.getInputStream()));

these two pieces of code are how I get info and send info to the C program, which is also the server where the java program is the client, thank you in advance.

Was it helpful?

Solution

You can make a Timer object that checks your stream for more data, if it needs to be a Timer that makes an event on the EDT it can be a javax.swing.Timer, if not you can make a java.util.Timer.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top