Solved

JNI to C++ socket app.

Posted on 2006-11-03
6
324 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
Free Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

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

 

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

Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

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

Suggested Solutions

Title # Comments Views Activity
numbers ascending pyramid 101 214
factorial example 4 50
use lov values 2 64
JavaFX TableView not displaying correctly 3 62
For beginner Java programmers or at least those new to the Eclipse IDE, the following tutorial will show some (four) ways in which you can import your Java projects to your Eclipse workbench. Introduction While learning Java can be done with…
Introduction This article is the last of three articles that explain why and how the Experts Exchange QA Team does test automation for our web site. This article covers our test design approach and then goes through a simple test case example, how …
Video by: Michael
Viewers learn about how to reduce the potential repetitiveness of coding in main by developing methods to perform specific tasks for their program. Additionally, objects are introduced for the purpose of learning how to call methods in Java. Define …
Viewers learn how to read error messages and identify possible mistakes that could cause hours of frustration. Coding is as much about debugging your code as it is about writing it. Define Error Message: Line Numbers: Type of Error: Break Down…

821 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