We help IT Professionals succeed at work.

We've partnered with Certified Experts, Carl Webster and Richard Faulkner, to bring you two Citrix podcasts. Learn about 2020 trends and get answers to your biggest Citrix questions!Listen Now

x

JNI to C++ socket app.

phongtran72
phongtran72 asked
on
Medium Priority
355 Views
Last Modified: 2012-06-21

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
Comment
Watch Question

Top Expert 2006

Commented:
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

Author

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
Top Expert 2006

Commented:
Yes, why are you thinking negative ?

Author

Commented:


why are you thinking negative

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

Thanks
Top Expert 2006
Commented:
If you can do it with C++, You can with JNI
Perhaps you are not doing it the right way

Not the solution you were looking for? Getting a personalized solution is easy.

Ask the Experts

Author

Commented:
Thanks. I'll write a small program to investigate this issue.
I'll let you know the result.
Access more of Experts Exchange with a free account
Thanks for using Experts Exchange.

Create a free account to continue.

Limited access with a free account allows you to:

  • View three pieces of content (articles, solutions, posts, and videos)
  • Ask the experts questions (counted toward content limit)
  • Customize your dashboard and profile

*This site is protected by reCAPTCHA and the Google Privacy Policy and Terms of Service apply.

OR

Please enter a first name

Please enter a last name

8+ characters (letters, numbers, and a symbol)

By clicking, you agree to the Terms of Use and Privacy Policy.