Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

JNI to C++ socket app.

Posted on 2006-11-03
6
Medium Priority
?
343 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
0
Comment
Question by:phongtran72
  • 3
  • 3
6 Comments
 
LVL 14

Expert Comment

by:hoomanv
ID: 17867608
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
 

Author Comment

by:phongtran72
ID: 17867675
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
 
LVL 14

Expert Comment

by:hoomanv
ID: 17867709
Yes, why are you thinking negative ?
0
VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

 

Author Comment

by:phongtran72
ID: 17870539


why are you thinking negative

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

Thanks
0
 
LVL 14

Accepted Solution

by:
hoomanv earned 2000 total points
ID: 17872891
If you can do it with C++, You can with JNI
Perhaps you are not doing it the right way
0
 

Author Comment

by:phongtran72
ID: 17875152
Thanks. I'll write a small program to investigate this issue.
I'll let you know the result.
0

Featured Post

Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

By the end of 1980s, object oriented programming using languages like C++, Simula69 and ObjectPascal gained momentum. It looked like programmers finally found the perfect language. C++ successfully combined the object oriented principles of Simula w…
In this post we will learn how to make Android Gesture Tutorial and give different functionality whenever a user Touch or Scroll android screen.
Viewers learn about the “for” loop and how it works in Java. By comparing it to the while loop learned before, viewers can make the transition easily. You will learn about the formatting of the for loop as we write a program that prints even numbers…
How to fix incompatible JVM issue while installing Eclipse While installing Eclipse in windows, got one error like above and unable to proceed with the installation. This video describes how to successfully install Eclipse. How to solve incompa…
Suggested Courses

916 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question