nsComponentManager::RegisterComponent(kEventQueueServiceCID, NULL, NULL, XPCOM_DLL, PR_FALSE, PR_FALSE);
main(int argc, char* argv[]){    nsresult rv= -1;    if (argc < 2) {        printf("usage: %s <url> \n", argv[0]);        return -1;    }    /*         The following code only deals with XPCOM registration stuff. and setting        up the event queues. Copied from TestSocketIO.cpp    */    // XXX why do I have to do this?!    nsComponentManager::RegisterComponent(kEventQueueServiceCID, NULL, NULL, XPCOM_DLL, PR_FALSE, PR_FALSE);    rv = nsComponentManager::AutoRegister(nsIComponentManager::NS_Startup,                                        "components");    if (NS_FAILED(rv)) return rv;    // Create the Event Queue for this thread...    NS_WITH_SERVICE(nsIEventQueueService, eventQService, kEventQueueServiceCID, &rv);    if (NS_FAILED(rv)) return rv;    nsIEventQueue* eventQ;    rv = eventQService->CreateThreadEventQueue();    if (NS_FAILED(rv)) return rv;    eventQService->GetThreadEventQueue(PR_CurrentThread(), &eventQ);    //Create the nsINetService...    NS_WITH_SERVICE(nsINetService, pService, kNetServiceCID, &rv);    if (NS_FAILED(rv)) return rv;    // The story of how to retrieve a document. 	// Now available in 2 different flavours.    if (pService)    {        nsCOMPtr<nsIUrl> pURL;        if (NS_OK == pService->NewUrl("http://gagan.mcom.com/", getter_AddRefs(pURL)))        {            if (pURL)            {                nsCOMPtr<nsIProtocolConnection> pConnection;                if (NS_OK == pService->NewConnection(pURL, nsnull, nsnull, getter_AddRefs(pConnection)))                {                    /* Flavour One! */                    // Plain vanilla getting a file... in blocking mode                    nsCOMPtr<nsIInputStream> pStream;                    if (NS_OK == pConnection->GetInputStream(getter_AddRefs(pStream)))                    {                        if (pStream)                        {                            char buffer[1024];                            PRUint32 readCount;                            do                             {                                if (NS_OK == pStream->Read(buffer, 1024, &readCount))                                {                                    printf(buffer);                                }                            }                            while (readCount != 0);                        }                    }                }#if 0                /* Flavour Two */                // Async reading thru the calls of the event sink interface                if (NS_OK == pService->NewConnection(pURL, pMyConsumer, nsnull, getter_AddRefs(pConnection)))                {                    if (pConnection)                    {                        /*                             You may optionally add/set other headers on this                            request object. This is done by QI for the specific                            protocolConnection.                        */                        nsCOMPtr<nsIHTTPConnection> pHTTPCon(pConnection);                        if (pHTTPCon)                        {                            // Setting a sample user agent string.                            if (NS_OK == pHTTPCon->SetAgent("Mozilla/5.0 [en] (Win98; U)"))                            {                            }                        }                                            // But calling the open is required!                        pConnection->Open();                    }                }#endif            }        }    }  // Enter the message pump to allow the URL load to proceed.  while ( gKeepRunning ) {#ifdef XP_PC    MSG msg;    if (GetMessage(&msg, NULL, 0, 0)) {      TranslateMessage(&msg);      DispatchMessage(&msg);    } else {      gKeepRunning = FALSE;    }#endif  }    return rv;}