/// <summary> /// Calls BIO_read() /// </summary> /// <param name="count"></param> /// <returns></returns> public ArraySegment <byte> ReadBytes(int count) { var buf = new byte[count]; var ret = Native.BIO_read(ptr, buf, buf.Length); if (ret < 0) { throw new OpenSslException(); } return(new ArraySegment <byte>(buf, 0, ret)); }
/// <summary> /// Calls BIO_read() /// </summary> /// <param name="count"></param> /// <returns></returns> 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)); }
/// <summary> /// Calls BIO_read() /// </summary> /// <param name="count"></param> /// <returns></returns> public ArraySegment <byte> ReadBytes(int count) { if (count == 0) { return(new ArraySegment <byte>(new byte[0])); } byte[] buf = new byte[count]; int ret = Native.BIO_read(this.ptr, buf, buf.Length); if (ret < 0) { throw new OpenSslException(); } return(new ArraySegment <byte>(buf, 0, ret)); }
/// <summary> /// Calls BIO_read using a user provided array. /// </summary> /// <param name="buf">User buffer</param> /// <param name="len">Maximum amount of bytes to read.</param> /// <returns>The amount of bytes read.</returns> public int Read(byte[] buf, int len) { return(Native.BIO_read(this.ptr, buf, len)); }