Example #1
0
        /// <summary>
        /// Obtain status information for a Multi transfer.
        /// </summary>
        /// <returns>
        /// An array of <see cref="MultiInfo"/> objects, one for each
        /// <see cref="Easy"/> object child.
        /// </returns>
        /// <exception cref="System.NullReferenceException">
        /// This is thrown if the native <c>Multi</c> handle wasn't
        /// created successfully.
        /// </exception>
        public MultiInfo[] InfoRead()
        {
            if (m_bGotMultiInfo)
            {
                return(m_multiInfo);
            }
            m_bGotMultiInfo = true;

            int    nMsgs = 0;
            IntPtr pInfo = External.curl_shim_multi_info_read(m_pMulti,
                                                              ref nMsgs);

            if (pInfo != IntPtr.Zero)
            {
                int msgSize = sizeof(Int32) * 2 + IntPtr.Size;
                m_multiInfo = new MultiInfo[nMsgs];
                for (int i = 0; i < nMsgs; i++)
                {
                    CURLMSG msg = (CURLMSG)Marshal.ReadInt32(
                        pInfo, i * msgSize);
                    IntPtr pEasy = Marshal.ReadIntPtr(
                        pInfo, i * msgSize + sizeof(Int32));
                    CURLcode code = (CURLcode)Marshal.ReadInt32(
                        pInfo, i * msgSize + sizeof(Int32) + IntPtr.Size);
                    m_multiInfo[i] = new MultiInfo(msg,
                                                   (Easy)m_htEasy[pEasy], code);
                }
                External.curl_shim_multi_info_free(pInfo);
            }
            return(m_multiInfo);
        }