I have a c++ application which in essence makes a connection to a server blocks on it to listen and when it gets a message from the server, dispatches the message received to a thread and then blocks on listen again (forever).
The question here is can I use JNI to invoke the c++ application (call the main function of the c++ code) and get the message back to the java layer and process it? The literature says JNI is used for invoking c/c++ libraries from java but can the above c++ application be considered a library? Or is JNI just used for calling c++ native functions where in a call from java is made and the control passes to c++ and then back to java?
The c++ application above use pthreads and blocks on listen and the control would pass only to java layer when a message which was processed from c++ layer is passed to java layer. Any pointer for clarification on the above would be much appreciated.