Mercurial > hg > ucis.core
annotate 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 |
rev | line source |
---|---|
1
28dc7d535036
Small improvements, introduced PacketStream
Ivo Smits <Ivo@UCIS.nl>
parents:
diff
changeset
|
1 ???using System; |
28dc7d535036
Small improvements, introduced PacketStream
Ivo Smits <Ivo@UCIS.nl>
parents:
diff
changeset
|
2 using System.IO; |
28dc7d535036
Small improvements, introduced PacketStream
Ivo Smits <Ivo@UCIS.nl>
parents:
diff
changeset
|
3 |
28dc7d535036
Small improvements, introduced PacketStream
Ivo Smits <Ivo@UCIS.nl>
parents:
diff
changeset
|
4 namespace UCIS.Util { |
28dc7d535036
Small improvements, introduced PacketStream
Ivo Smits <Ivo@UCIS.nl>
parents:
diff
changeset
|
5 public abstract class PacketStream : Stream { |
28dc7d535036
Small improvements, introduced PacketStream
Ivo Smits <Ivo@UCIS.nl>
parents:
diff
changeset
|
6 public abstract Byte[] ReadPacket(); |
28dc7d535036
Small improvements, introduced PacketStream
Ivo Smits <Ivo@UCIS.nl>
parents:
diff
changeset
|
7 public abstract IAsyncResult BeginReadPacket(AsyncCallback callback, object state); |
28dc7d535036
Small improvements, introduced PacketStream
Ivo Smits <Ivo@UCIS.nl>
parents:
diff
changeset
|
8 public abstract Byte[] EndReadPacket(IAsyncResult asyncResult); |
28dc7d535036
Small improvements, introduced PacketStream
Ivo Smits <Ivo@UCIS.nl>
parents:
diff
changeset
|
9 |
28dc7d535036
Small improvements, introduced PacketStream
Ivo Smits <Ivo@UCIS.nl>
parents:
diff
changeset
|
10 public virtual ArraySegment<Byte> ReadPacketFast() { return new ArraySegment<byte>(ReadPacket()); } |
28dc7d535036
Small improvements, introduced PacketStream
Ivo Smits <Ivo@UCIS.nl>
parents:
diff
changeset
|
11 public virtual IAsyncResult BeginReadPacketFast(AsyncCallback callback, object state) { return BeginReadPacket(callback, state); } |
28dc7d535036
Small improvements, introduced PacketStream
Ivo Smits <Ivo@UCIS.nl>
parents:
diff
changeset
|
12 public virtual ArraySegment<Byte> EndReadPacketFast(IAsyncResult asyncResult) { return new ArraySegment<byte>(EndReadPacket(asyncResult)); } |
28dc7d535036
Small improvements, introduced PacketStream
Ivo Smits <Ivo@UCIS.nl>
parents:
diff
changeset
|
13 public virtual void WritePacketFast(Byte[] packet, int unusedBefore, int unusedAfter) { Write(packet, unusedBefore, packet.Length - unusedBefore - unusedAfter); } |
28dc7d535036
Small improvements, introduced PacketStream
Ivo Smits <Ivo@UCIS.nl>
parents:
diff
changeset
|
14 public virtual int WriteFastBytesBefore { get { return 0; } } |
28dc7d535036
Small improvements, introduced PacketStream
Ivo Smits <Ivo@UCIS.nl>
parents:
diff
changeset
|
15 public virtual int WriteFastBytesAfter { get { return 0; } } |
28dc7d535036
Small improvements, introduced PacketStream
Ivo Smits <Ivo@UCIS.nl>
parents:
diff
changeset
|
16 } |
28dc7d535036
Small improvements, introduced PacketStream
Ivo Smits <Ivo@UCIS.nl>
parents:
diff
changeset
|
17 } |