public ArraySegment<byte> ReadBytes(int count)
{
byte[] buf = new byte[count];
int ret = Native.BIO_read(this.ptr, buf, buf.Length);
if (ret < 0)
throw new Exception("Expected " + count + " bytes but received " + ret);
return new ArraySegment<byte>(buf, 0, ret);
}