Java has built-in networking capabilities. It is totally possible to
have a Java-Based Network application connect to a C++-Based Network
Process. TCP streams are more than supported in Java, along with the
Java I/O classes. You can avoid JNI calls or local socket connections
to your local C++ process. You can eliminate all these rather confusing
techniques, and make it significantly faster - as long as the Java side
and the C++ side agree to some protocol or a set of rules you make to
get these two processes to understand each other.
If you totally need to have that local C++ process along with Java,
it's probably better to do it in JNI. It is very confusing, but
probably the best way to go. I do not believe that JNI calls are
buffered - then again, Java doesn't do a lot of things with calls
passes to JNI. You have to be careful with JNI as there are no
error-checking or garbage collection in C++. And an error in the C++
process can crash the JVM, so be mindful of what you program in C++.
> If you totally need to have that local C++ process along with Java,
> it's probably better to do it in JNI. It is very confusing, but
[quoted text clipped - 3 lines]
> error-checking or garbage collection in C++. And an error in the C++
> process can crash the JVM, so be mindful of what you program in C++.
Thanks for your reply. Unfortunately, I do have to talk to a local C++
process - it's actually a library that has a bunch of functionality.
However, as luck would have it, the socket solution doesn't work. I can
make a local connection to the C++ process, but it then fails to send
anything via its own remote connection. Otoh, if I disable my server
socket code, then it can send data just as before - but obviously not
receive new connections.
I think the fact that the C++ program has its own customized socket
somehow is fouling things up. There's some kind of network area that
has to be initilialized, I need to include some networking and io
headers - basically, it's DOA.
So, it looks like JNI is the way to go. Just as well - working with
that yukky MFC C++ code feels like being stuck inside a machine's brain
gone amuck. At least JNI is straight C.
- Chris