r1460@opsdev009 (orig r77478): dreiss | 2008-01-11 12:59:12 -0800
[amiethrift.git] / lib / csharp / src / Transport / TTransport.cs
blob90f7e74fe348918d0fb63ab4956201975abd0584
1 //
2 // TTransport.cs
3 //
4 // Begin: Aug 19, 2007
5 // Authors:
6 // Todd Berman <tberman@imeem.com>
7 //
8 // Copyright (C) 2007 imeem, inc. <http://www.imeem.com>
9 // All rights reserved.
12 using System;
13 using System.Collections.Generic;
14 using System.Text;
16 namespace Thrift.Transport
18 public abstract class TTransport
20 public abstract bool IsOpen
22 get;
25 public bool Peek()
27 return IsOpen;
30 public abstract void Open();
32 public abstract void Close();
34 public abstract int Read(byte[] buf, int off, int len);
36 public int ReadAll(byte[] buf, int off, int len)
38 int got = 0;
39 int ret = 0;
41 while (got < len)
43 ret = Read(buf, off + got, len - got);
44 if (ret <= 0)
46 throw new TTransportException("Cannot read, Remote side has closed");
48 got += ret;
51 return got;
54 public abstract void Write(byte[] buf, int off, int len);
56 public virtual void Flush()