Zum Inhalt springen
View in the app

A better way to browse. Learn more.

Fachinformatiker.de

A full-screen app on your home screen with push notifications, badges and more.

To install this app on iOS and iPadOS
  1. Tap the Share icon in Safari
  2. Scroll the menu and tap Add to Home Screen.
  3. Tap Add in the top-right corner.
To install this app on Android
  1. Tap the 3-dot menu (⋮) in the top-right corner of the browser.
  2. Tap Add to Home screen or Install app.
  3. Confirm by tapping Install.

Asynchroner Internetzugriff

Empfohlene Antworten

Veröffentlicht

Hallo zusammen,

da Ihr die Fortsetzung meines Thread weiter unten ja erfolgreich ignoriert habt, versuche ich es hier jetzt nochmal ;)

Ich habe mein Problem mal gänzlich in eine eigene Mini-App isoliert, den Code seht Ihr unten. Mein Problem ist weiterhin, dass alle Funktionen erfolgreich aufgerufen werden, d.h. der Zugriff auf die Url sollte eingeleitet sein. Im synchronen Modus klappt's auch. Allerdings kommt im asynchronen Modus meine Callback-Funktion (AsyncFunc(...), siehe unten) nie zum Aufruf.

VOID CALLBACK AsyncFunc(

IN HINTERNET hInternet,

IN DWORD dwContext,

IN DWORD dwInternetStatus,

IN LPVOID lpvStatusInformation,

IN DWORD dwStatusInformationLength

)

{

MessageBox(NULL, "Callback-Funktion wurde aufgerufen", "", 0);

}

int APIENTRY WinMain(HINSTANCE hInstance,

HINSTANCE hPrevInstance,

LPSTR lpCmdLine,

int nCmdShow )

{

HANDLE hSession = NULL, hResource = NULL;

hSession = InternetOpen("TestApp", INTERNET_OPEN_TYPE_PRECONFIG, NULL, NULL, INTERNET_FLAG_ASYNC);

InternetSetStatusCallback(hSession, (INTERNET_STATUS_CALLBACK)AsyncFunc);

hResource = InternetOpenUrl(hSession, "ftp://ftp.microsoft.com/developr/readme.txt", NULL, 0, 0, 0);

DWORD dw = GetLastError();

if( !hResource && (dw == ERROR_IO_PENDING))

MessageBox(NULL, "Anfrage läuft", "", 0);

// Warten, und warten, und weiter warten....schnarch

// Schleife, Dialog o.ä.

if(hResource)

InternetCloseHandle(hResource);

if(hSession)

InternetCloseHandle(hSession);

return 0;

}

Hat jemand eine Idee??

Nochmal Danke und Gruß

  • Autor

Leider kann ich nicht direkt über Ftp rausgehen, da unser CERN-Proxy das unterbindet. Die entsprechenden Funktionen schlagen somit alle fehl. Ich muss also das HTTP-Protokoll benutzen (InternetOpenUrl(..)), dann klappt der Funktionsaufruf, nur - wie oben beschrieben - die Callback-Funktion macht ärger!

  • Autor

Hab des Rätsel's Lösung selbst gefunden: man MUSS (!!!!!) der Funktion, die asynchron aufgerufen werden soll, irgendeinen DWORD im Parameter dwContext mit auf den Weg geben, der dann an die Callback-Funktion weitergegeben wird. Tut man dies nicht (z.B., weil man gar keine weiteren Infos in der Callback-Funktion braucht), macht good old Windows aus der asynchronen Funktion eine synchrone. Danke, Billy...

Archiv

Dieses Thema wurde archiviert und kann nicht mehr beantwortet werden.

Configure browser push notifications

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions → Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.