package org.kne.cloud.network.klalb; import java.io.DataOutputStream; import java.io.IOException; import java.io.OutputStream; import java.net.Inet6Address; import java.nio.ByteBuffer; import java.nio.channels.Channels; import java.nio.channels.WritableByteChannel; public class KLALBOutputStream extends DataOutputStream { private WritableByteChannel channel; public KLALBOutputStream(OutputStream out) throws IOException { super(out); this.channel=Channels.newChannel(out); byte[]b=new byte[] {'K','L','A','L','B'}; write(b); writeInt(CONST.bversion); writeInt(CONST.sversion); flush(); } public void writeKLALBPacket(KLALBPacket klb) throws IOException { writeInt((int) klb.getTotalLength()); KLALBPacket.writeKLALBPacketToStream(this, klb); } public void writePacket(ByteBuffer kp) throws IOException { writeInt( kp.limit()); channel.write(kp); } }