BIO_read() 개인적인 메소드

private BIO_read ( IntPtr b, byte buf, int len ) : int
b System.IntPtr
buf byte
len int
리턴 int
예제 #1
0
        /// <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));
        }
예제 #2
0
        /// <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));
        }
예제 #3
0
        /// <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));
        }
예제 #4
0
 /// <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));
 }