Problem with socket in java and c++ - Programmers Heaven

Howdy, Stranger!

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


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.