Send a 0 byte using DataOutputStream?

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的数组,单个元素设置为0?

out.write(new byte[]{0});
链接地址: http://www.djcxy.com/p/56566.html

上一篇: “通过对等方重置连接”是什么意思?

下一篇: 使用DataOutputStream发送一个0字节?