1

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?

Tinus Tate
  • 2,237
  • 2
  • 12
  • 33

1 Answers1

6

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

out.write(new byte[]{0});
Brian Agnew
  • 268,207
  • 37
  • 334
  • 440