Skip to Main Content

Java Programming

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

Problem with socket in java and c++

807588Jul 10 2009 — edited Jul 11 2009
I am connecting to a server developed in java that use sys/socket.h, this server use DataInputStream
class and readUTF so:


in = new DataInputStream(socket.getInputStream());
inputString = in.readUTF()

My application in C++ it use winsock2.h and I utilize the method "send" in order to send the plots to the server
java got hold of:

#define MAXLONGITUD 10000
char bufEnviados[MAXLONGITUD + 1];

bufEnviados[0] = (0xff & (longitud >> 8));
bufEnviados[1] = (0xff & longitud);

send(sock, bufEnviados,strlen(bufEnviados), 0 );

I send the two first characters with UTF format so that the server in java could recognize them.

The application operated correctly it until received an old plot of 6.236 characters later
from which it close the connection with the socket and it fall my application!

I have carried out several tests and I don't succeed in sending more than those 6.236 characters, however it achievement receibing whatever quantity of characters without problems!

Could somebody help me to resolve this problem? I am attempting of everything and I don't achieve it!

Ahead of time thank you!
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Aug 8 2009
Added on Jul 10 2009
4 comments
381 views