Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Categories

Welcome to the new platform of Programmer's Heaven! We apologize for the inconvenience caused, if you visited us from a broken link of the previous version. The main reason to move to a new platform is to provide more effective and collaborative experience to you all. Please feel free to experience the new platform and use its exciting features. Contact us for any issue that you need to get clarified. We are more than happy to help you.

Problem with socket in java and c++

alfaximenaalfaximena Posts: 1Member
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!
Sign In or Register to comment.