Reputation: 2365
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?
Upvotes: 1
Views: 764
Reputation: 272417
Surely you just want an array of length 1, with the single element set to 0 ?
out.write(new byte[]{0});
Upvotes: 6