0
votes

I'm creating an server for an existing client. This client reads input from server using a socket and DataInputStream. It checks for end of server message using:

byte c = in.readByte();
if( c == 0) { //the end.

On the server i'm using a serversocket and DataOutputStream to send message to client:

out.write(bytes[])

How can i send a 0 byte so that the client knows it is the end of the message?

1
a DataOutputStream does have a method called writeByte. Why don't you just use that? - ParkerHalo

1 Answers

5
votes

Surely you just want an array of length 1, with the single element set to 0 ?

out.write(new byte[]{0});