Mercurial > hg > ucis.core
view Util/PacketStream.cs @ 36:c4a5dbe62513
USBLib: small fix in WinUSB backend bounds checking
author | Ivo Smits <Ivo@UCIS.nl> |
---|---|
date | Sun, 21 Apr 2013 18:32:43 +0200 |
parents | 28dc7d535036 |
children |
line wrap: on
line source
???using System; using System.IO; namespace UCIS.Util { public abstract class PacketStream : Stream { public abstract Byte[] ReadPacket(); public abstract IAsyncResult BeginReadPacket(AsyncCallback callback, object state); public abstract Byte[] EndReadPacket(IAsyncResult asyncResult); public virtual ArraySegment<Byte> ReadPacketFast() { return new ArraySegment<byte>(ReadPacket()); } public virtual IAsyncResult BeginReadPacketFast(AsyncCallback callback, object state) { return BeginReadPacket(callback, state); } public virtual ArraySegment<Byte> EndReadPacketFast(IAsyncResult asyncResult) { return new ArraySegment<byte>(EndReadPacket(asyncResult)); } public virtual void WritePacketFast(Byte[] packet, int unusedBefore, int unusedAfter) { Write(packet, unusedBefore, packet.Length - unusedBefore - unusedAfter); } public virtual int WriteFastBytesBefore { get { return 0; } } public virtual int WriteFastBytesAfter { get { return 0; } } } }