rv = NS_AutoregisterComponents(); if (NS_FAILED(rv)) return rv;
nsCOMPtr<nsIServiceManager> servMan; NS_InitXPCOM2(getter_AddRefs(servMan), nsnull, nsnull); nsCOMPtr<nsIComponentRegistrar> registrar = do_QueryInterface(servMan); NS_ASSERTION(registrar, "Null nsIComponentRegistrar"); registrar->AutoRegister(nsnull);
main(int argc, char* argv[]){  nsresult rv;  if (argc < 2) {      printf("usage: %s <host>\n", argv[0]);      return -1;  }  int port;  char* hostName = argv[1];//nsString portString(argv[2]);//port = portString.ToInteger(&rv);  port = 13;  rv = NS_AutoregisterComponents();  if (NS_FAILED(rv)) return rv;  // Create the Event Queue for this thread...  nsCOMPtr<nsIEventQueueService> eventQService =            do_GetService(kEventQueueServiceCID, &rv);  if (NS_FAILED(rv)) return rv;  rv = eventQService->CreateThreadEventQueue();  if (NS_FAILED(rv)) return rv;  nsCOMPtr<nsIEventQueue> eventQ;  rv = eventQService->GetThreadEventQueue(NS_CURRENT_THREAD, getter_AddRefs(eventQ));  if (NS_FAILED(rv)) return rv;  nsCOMPtr<nsISocketTransportService> sts =            do_GetService(kSocketTransportServiceCID, &rv);  if (NS_FAILED(rv)) return rv;  nsITransport* transport;  rv = sts->CreateTransport(hostName, port, nsnull, 0, 0, &transport);  if (NS_SUCCEEDED(rv)) {    nsCOMPtr<nsIRequest> request;    transport->AsyncRead(nsnull, new InputTestConsumer, 0, -1, 0, getter_AddRefs(request));    NS_RELEASE(transport);  }  // Enter the message pump to allow the URL load to proceed.  while ( gKeepRunning ) {#ifdef WIN32    MSG msg;    if (PeekMessage(&msg, NULL, 0, 0, PM_REMOVE)) {      TranslateMessage(&msg);      DispatchMessage(&msg);    }#else#ifdef XP_MAC    /* Mac stuff is missing here! */#else#ifdef XP_OS2    QMSG qmsg;    if (WinGetMsg(0, &qmsg, 0, 0, 0))      WinDispatchMsg(0, &qmsg);    else      gKeepRunning = FALSE;#else    PLEvent *gEvent;    rv = eventQ->GetEvent(&gEvent);    rv = eventQ->HandleEvent(gEvent);#endif#endif#endif  }  sts->Shutdown();  return 0;}