TCHAR in c++ to string in java

D

dwurity

Hi-
I am developing file transfer application, the host is in c++ and the
client is in java. In c++ I am using win32_find_data to get all the
files list and i am sending it to the client through the stream.

The client will reads all the specified information, but i am getting
some blocks in the middle, I hope the problem will be at the reading
side. The host will sends the data in form of win32_find_data format,
and here i am reading the information, so i want how to process the
fileName which is the field of the structure win32_find_data, at the
client side (java side), should i use the charsetdecoder to convert the
type TCHAR(fileName) data to string at java???
Thanks in advance,
dwurity
 
M

Michael Borgwardt

The client will reads all the specified information, but i am getting
some blocks in the middle, I hope the problem will be at the reading
side. The host will sends the data in form of win32_find_data format,
and here i am reading the information, so i want how to process the
fileName which is the field of the structure win32_find_data, at the
client side (java side), should i use the charsetdecoder to convert the
type TCHAR(fileName) data to string at java???

No, you should define a portable communications protocol. C structs are
not portable. When the protocol is clearly defined (that includes
specifying the charset of Strings) then implementing it on the Java side
will be straightforward.

As it is, your host is fundamentally broken.
 
B

Bobby

No, i verified the host with another client which was writtened in c++
and its working great with out any problems, the problem occured only
with the java client!

what is the problem???

Thanks,
dwurity
 
B

Bobby

Hi-

No, my host is working very well when I use the client which was done
in c++, but it was the problem with the client written in java, what
could be wrong???

Thanks,
dwurity
 
B

Bobby

Hi-

No, my host is working very well when I use the client which was done
in c++, but it was the problem with the client written in java, what
could be wrong???

Thanks,
dwurity
 
B

Bobby

Hi-

No, my host is working very well when I use the client which was done
in c++, but it was the problem with the client written in java, what
could be wrong???

Thanks,
dwurity
 
M

Michael Borgwardt

Bobby said:
No, i verified the host with another client which was writtened in c++
and its working great with out any problems,

That does not, in any way, constitute a "verification".
the problem occured only
with the java client!

what is the problem???

The problem is still that you do NOT have a clearly defined, portable
communication protocol. Using C structs is an amateurish mistake, because
they differ between compilers and architectures. Your C++ client may
not work anymore when compiled with a different compiler or on a different
machine.

Define *exactly* what the host sends over the network, byte by byte, what
fields of what length and with what content (including endianness and
character encoding). Then implement that in Java.

And stop those multiple reposts!
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,764
Messages
2,569,566
Members
45,041
Latest member
RomeoFarnh

Latest Threads

Top