annotate Util/PacketStream.cs @ 1:28dc7d535036

Small improvements, introduced PacketStream
author Ivo Smits <Ivo@UCIS.nl>
date Mon, 07 Jan 2013 16:43:28 +0100
parents
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
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 }