Problem when connecting Java App with C++ App using Windows So

Problem when connecting Java App with C++ App using Windows So

Post by S2V2aW4gTF » Fri, 29 May 2009 15:05:01


hanks, Remy ! Your comment is much helpful to us, so that we can put
attention to the Java App, not waste time on suspecting the synchronous mode
of socket and etc.

However, i think the best way to test is to make a simple Java App which
provide similar server functionality: listen for new connection, and write
some data to client. However, I have little experience in java programming,
could it possible for you to give me some advice or simple java code segment
to do so (listen and write data)?

For other issue, see my comment below please.

"Remy Lebeau" wrote:


*** I am not much clear, according to the running log, the Java App just
report Socket (connected with ###IP) error. I used to take a short look at
their code segment, seemed the Java App catch the IOException.


*** the reason we use asynchronous mode socket is that we just have a class
dedicated to connet a lot of different socket servers using asynchronous mode
connect() method. This class has 2 threads in it, one for connecting, and the
other for checking connecting result. In our experience, if one server is not
reachable, the synchronous mode connect() method may wait for a long time (10
seconds or even more), so in order to avoid affecting connecting operations
to other servers in case of some servers not reachable, we choose
asynchronous mode.


*** And, we do have a general class for communicating with servers using
socket. This class has 2 threads in it, one for read using blocking recv()
method, the other will check a data queue to see whether there is data to
send, if no, the thread is blocked, thus the read and write operation on the
socket are totally seperate, and the performance may be better. we do know
this may result in comsuming much more threads, but in our case, we generally
have 20-30 servers to communicate at most, so the thread comsumption is not a
big issue. In case of large amount of servers (indeed, we do have such an App
with 300 servers to connect), we choose IOCP method so that we can use
limited threads to serve the communication, but IOCP is much more complicated
and asynchronous mode nust be employed. This new method is under testing.



 
 
 

Problem when connecting Java App with C++ App using Windows So

Post by S2V2aW4gTF » Fri, 29 May 2009 20:16:07


*** Yes, we will ask them to use getMessage() to get detailed error messages
when
socket error detected.



*** Both the C++ client and Java Server run in Windows environment. And we
use XML as the data format, and if connection is OK, the client and server
and
exchange data correctly, so we don't think this problem is related to htonl().


*** The developer of Java App did use some a network-packet-catch tool
(Ethereal) to check why the Java app often detects socket error. As he said,
there was a TCP Ack packet lost when error occurs. However, becuase both C++
and Java are on the socket layer (not the TCP low layer), we don't know why
TCP Ack packet lost.

 
 
 

Problem when connecting Java App with C++ App using Windows So

Post by Remy Lebea » Sat, 30 May 2009 03:40:05


Those kind of issues are at the OS networking level, not at the application
level. There is nothing you can do about them at the application level.
You have a networking issue, not a coding issue.

--
Remy Lebeau (TeamB)
 
 
 

Problem when connecting Java App with C++ App using Windows So

Post by S2V2aW4gTF » Sat, 30 May 2009 15:11:01

Hi, Remy,

For the same WAN environment which socket error problem between the 2
Apps occured, we did make such a test : put the C++ client and Java Server in
same computer, they work well, and C++ client connect to another C++ server
across the WAN, the C++ client and C++ Server work well too. So, we don't
think this is due to network issue. Only 2 possible reason we can imagine:
first, maybe the Java App program problem (as you suggested), the other is
the cooperation issue between C++ socket and Java socket (both are in Windows
environment), but you suggested that this should not be a issue.