My application in C + + uses winsock2.h It use the send method to send the frames to the server developend on java.

My application send a string so:

#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. Java Use readUTF to receive de string.

The application operated correctly it until received a string 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!

Recommended Answers

All 2 Replies

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

strlen() won't work on unicode strings. usel (wcslen(bufEnviados)+1) * sizeof(wchar_t) instead. wcslen() is declared in wchar.h -- I don't know if it is portable to all compilers or not.

I think you need to use wchar in lieu of char as well.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.