0-1
数据在网络传输过程中以字节流形式流通,封装一个用于读写字节流的类那是必须的必!
ByteBuffer
using System.IO;
using System.Text;
using System;
namespace Net {
public class ByteBuffer
{
MemoryStream stream = null;
BinaryWriter writer = null;
BinaryReader reader = null;
public ByteBuffer()
{
stream = new MemoryStream();
writer = new BinaryWriter(stream);
}
public ByteBuffer(byte[] data)
{
if (data != null) {
stream = new MemoryStream(data);
reader = new BinaryReader(stream);
} else {
stream = new MemoryStream();
writer = new BinaryWriter(stream);
}
}
public void Close()
{
if (writer != null) writer.Close();
if