M
markobrien85
G'day
I'm attempting to get Java to communicate to an existing application
using sockets. My first step was getting a simple java client and echo
server setup as a sort of hello world and introduction into java. Now
when I modify my java server to simply print out messages received
from the client (no sending information back out at this stage) I run
into a problem when I use my non-java client.
My client program sends out null terminated messages using UTF-8
encoding. This can not be modified. Java however treats strings as
classes and from what I could gather stores the length of the string
in the first two bytes.
Java blocks and does not return after my call to readUTF() of my
sockets input steam. My input stream is declared as: is = new
DataInputStream( new BufferedInputStream( sock.getInputStream() ));
This lead me to believe its the internal string representation in java
thats causing me the troubles. I also tried reading in characters one
at time using is.getChar() but that returned some Asian characters,
ie the character encoding java was using wasn't using UTF-8.
A look through the java doc's didn't reveal any obvious ways to parse
in a null terminated string. Any help very, very, very much
appericated
I'm attempting to get Java to communicate to an existing application
using sockets. My first step was getting a simple java client and echo
server setup as a sort of hello world and introduction into java. Now
when I modify my java server to simply print out messages received
from the client (no sending information back out at this stage) I run
into a problem when I use my non-java client.
My client program sends out null terminated messages using UTF-8
encoding. This can not be modified. Java however treats strings as
classes and from what I could gather stores the length of the string
in the first two bytes.
Java blocks and does not return after my call to readUTF() of my
sockets input steam. My input stream is declared as: is = new
DataInputStream( new BufferedInputStream( sock.getInputStream() ));
This lead me to believe its the internal string representation in java
thats causing me the troubles. I also tried reading in characters one
at time using is.getChar() but that returned some Asian characters,
ie the character encoding java was using wasn't using UTF-8.
A look through the java doc's didn't reveal any obvious ways to parse
in a null terminated string. Any help very, very, very much
appericated