Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
CODE PROJECT For Those Who Code
  • Home
  • Articles
  • FAQ
Community
  1. Home
  2. General Programming
  3. C / C++ / MFC
  4. Detecting slow Internet connection

Detecting slow Internet connection

Scheduled Pinned Locked Moved C / C++ / MFC
c++htmlagentic-aihelpquestion
1 Posts 1 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • J Offline
    J Offline
    Jose Luis Sogorb
    wrote on last edited by
    #1

    How could I abort an http download if the connection is too slow? For instance, if I have this code using MFC_Tear_Sample void getHttp() { CString pszURL = "http://weather.noaa.gov/weather/current/"; CString uneURL; BOOL bStripMode = FALSE; DWORD dwAccessType = PRE_CONFIG_INTERNET_ACCESS; DWORD dwHttpRequestFlags = INTERNET_FLAG_EXISTING_CONNECT | INTERNET_FLAG_NO_AUTO_REDIRECT | INTERNET_FLAG_RELOAD; const TCHAR szHeaders[] = _T("Accept: text/*\r\nUser-Agent: MFC_Tear_Sample\r\n"); FILE *fp1; int nRetCode = 0; CTearSession session(_T("TEAR - MFC Sample App"), dwAccessType); CHttpConnection* pServer = NULL; CHttpFile* pFile = NULL; uneURL=pszURL+selEstacion+".html"; try { // check to see if this is a reasonable URL CString strServerName; CString strObject; INTERNET_PORT nPort; DWORD dwServiceType; if (!AfxParseURL(uneURL, dwServiceType, strServerName, strObject, nPort) || dwServiceType != INTERNET_SERVICE_HTTP) { MessageBox(0,"Error: Solo se pueden usar direcciones que comiencen con http://","Error en URL",MB_OK); ThrowTearException(1); } pServer = session.GetHttpConnection(strServerName, nPort); pFile = pServer->OpenRequest(CHttpConnection::HTTP_VERB_GET, strObject, NULL, 1, NULL, NULL, dwHttpRequestFlags); pFile->AddRequestHeaders(szHeaders); pFile->SendRequest(); if((fp1=fopen("temp.htm","wb"))!=NULL) { TCHAR sz[1024]; while (pFile->ReadString(sz, 1023)) { fputs(sz,fp1); } httpLeido =TRUE; } else AfxMessageBox("No se han podido encontrar, en estos momentos, datos sobre dicha estación"); fclose(fp1); } catch (CInternetException* pEx) { // catch errors from WinINet CString szErr; szErr.Format("Internet Exception Error %d", pEx->m_dwError); MessageBox(0,szErr,"ERROR",MB_OK); pEx->Delete(); } catch (CTearException* pEx) { // catch things wrong with parameters, etc nRetCode = pEx->m_nErrorCode; TRACE1("Error: Exiting with CTearException(%d)\n", nRetCode); pEx->Delete(); } if (pFile != NULL) { pFile->Close(); delete pFile; } if (pServer != NULL) { pServer->Close(); delete pServer; } session.Close(); }

    1 Reply Last reply
    0
    Reply
    • Reply as topic
    Log in to reply
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes


    • Login

    • Don't have an account? Register

    • Login or register to search.
    • First post
      Last post
    0
    • Categories
    • Recent
    • Tags
    • Popular
    • World
    • Users
    • Groups