JNI to C++ socket app.


Hi exprts,

I need to create a Java program that connect to a server via socket. The server is written in C++, and I have an API.lib and a header file to work with. The API.lib provides me a function void connect () to establish a socket connection. It is easy to build a C++ client using that function.
My question is: Can I create a Java client that connect dicrectly to C++ server using that function? (vua JNI)

Does the socket connection is made if I using JNI call the C++ function connect ()? (I will have a native C++ function wrap around that function, off course)

Thanks in advance
phongtran72Asked:
Who is Participating?

Improve company productivity with a Business Account.Sign Up

x
 
hoomanvConnect With a Mentor Commented:
If you can do it with C++, You can with JNI
Perhaps you are not doing it the right way
0
 
hoomanvCommented:
JNI needs a special paradigm to follow in order to call C functions from withing Java application
You should wrap all required functions according to the JNI style to create an acceptable dll for Java
0
 
phongtran72Author Commented:
to hoomanv
>>" wrap all required functions"

I only have one function "void connect()" from API.lib. This function would make a socket connection.

If I wrap this function with JNI style C++ function, a socket connection would be established?

Thanks for answering
0
Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

 
hoomanvCommented:
Yes, why are you thinking negative ?
0
 
phongtran72Author Commented:


why are you thinking negative

Because I cannot make a connection this way.
I am wondering if someone else can do it.

Thanks
0
 
phongtran72Author Commented:
Thanks. I'll write a small program to investigate this issue.
I'll let you know the result.
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.