Solved

JNI to C++ socket app.

Posted on 2006-11-03
6
315 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
Highfive + Dolby Voice = No More Audio Complaints!

Poor audio quality is one of the top reasons people don’t use video conferencing. Get the crispest, clearest audio powered by Dolby Voice in every meeting. Highfive and Dolby Voice deliver the best video conferencing and audio experience for every meeting and every room.

 

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 500 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

Find Ransomware Secrets With All-Source Analysis

Ransomware has become a major concern for organizations; its prevalence has grown due to past successes achieved by threat actors. While each ransomware variant is different, we’ve seen some common tactics and trends used among the authors of the malware.

Join & Write a Comment

Java contains several comparison operators (e.g., <, <=, >, >=, ==, !=) that allow you to compare primitive values. However, these operators cannot be used to compare the contents of objects. Interface Comparable is used to allow objects of a cl…
Introduction This article is the first of three articles that explain why and how the Experts Exchange QA Team does test automation for our web site. This article explains our test automation goals. Then rationale is given for the tools we use to a…
This tutorial covers a step-by-step guide to install VisualVM launcher in eclipse.
This tutorial explains how to use the VisualVM tool for the Java platform application. This video goes into detail on the Threads, Sampler, and Profiler tabs.

743 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

Need Help in Real-Time?

Connect with top rated Experts

8 Experts available now in Live!

Get 1:1 Help Now