hello,
i'm using wininet sdk having problem while i'm unloading wininet.dll.
here is seudocode
HMODULE hDll;
bool ret;
HINTERNET hInternet, hUrlHandle ;
char buf[1000];
hDll = LoadLibrary("wininet.dll");
// ret = FreeLibrary(hDll);
The FreeLibrary function takes lots of time in unloading the DLL. This code is running fine on windows XP but on 2000 this is taking too long time & on 98 it is crashing. Can any body help me out y this is happening.
My main concern is if i don't call InternetOpenURL API Freelibrary not take too long time, but if i call this api the FreeLibrary return after very long time.
if you need further detail plz ask me..
thanks,
Manish Birla.
usman999_1
February 25th, 2004, 05:10 AM
Why are loading that dll explicitly???? Why not include the Wininet.lib and call those Win32 Internet Functions from that lib i.e. then you don't need to use that GetProcAddress.
Hope this helps,
Regards,
Usman.
manish_birla
February 25th, 2004, 06:12 AM
thanks usman,
i'm writting a dll which is using wininet.dll. yeah i'm using wininet.lib in that dll. but while i'm unloading my dll it takes too long time. My dll has to loaded & unloaded explicitely.
while debugging i found because of wininet dll my dll taking long time to unload. than i write sample code which i have pasted in my query & run instruction by instruction. I found because of InternetOpenUrl function call it is taking long time. even i closed the handle returned from InternetOpenUrl api call. I'm using wininet sdk for making SSL connection.
I think now u got what is exact problem.
hankdane
February 25th, 2004, 06:29 PM
Why muck around with the library in the first place?
All WinInet calls are supported in the API. You don't need to open and free the library.
Myself dot NET
February 25th, 2004, 08:24 PM
Well, he needs to either implicitly or explicitly link to the WinInet library. Why he has chosen the more tedious explicit method I am unsure of, however.
Manish: are you sure it is the FreeLibrary() call causing these problems, or is it something else? The results of toggling InternetOpenUrl() indicates to me that it might be something else causing the slow down.
manish_birla
February 26th, 2004, 12:59 AM
i'm writting a dll which is using wininet.dll. yeah i'm using wininet.lib in that dll. but while i'm unloading my dll it takes too long time. My dll has to loaded & unloaded explicitely.
while debugging i found because of wininet dll my dll taking long time to unload. than i write sample code which i have pasted in my query & run instruction by instruction. I found because of InternetOpenUrl function call it is taking long timeto unload. even i closed the handle returned from InternetOpenUrl api call. I'm using wininet sdk for making SSL connection.
I think now u got what is exact problem.
manish_birla
February 26th, 2004, 02:26 AM
can any body tell me what is problem in sequence of API call. I think the problem is with InternetOpenURL api. but not getting what?? what could be possible error??? i mean weather there is error with sequence of calling the api or error with passing parameters?? I'm closing all handles before unloading properly. is there sth more to do?? If there is problem with parameter it should return error on calling of that particular API but api's r working fine. If i use wininet sdk.lib file this is working fine because i don't need to unload it. but problem is this i can't do.
Is this bug in microsoft wininet sdk itself? If anybody have any idea ab't this problem please let me know. I need to implement HTTPS connection, what is alternate way to do it on windows (98,2000, me &xp all should be supported)..please suggest for any other library or function. I can't use MFC. But i feel MFC classes also internally dependent on WININET sdk only. Please help me...
manish_birla
February 26th, 2004, 02:29 AM
can any body tell me what is problem in sequence of API call. I think the problem is with InternetOpenURL api. but not getting what?? what could be possible error??? i mean weather there is error with sequence of calling the api or error with passing parameters?? I'm closing all handles before unloading properly. is there sth more to do?? If there is problem with parameter it should return error on calling of that particular API but api's r working fine. If i use wininet sdk.lib file this is working fine because i don't need to unload it. but problem is this i can't do.
Is this bug in microsoft wininet sdk itself? If anybody have any idea ab't this problem please let me know. I need to implement HTTPS connection, what is alternate way to do it on windows (98,2000, me &xp all should be supported)..please suggest for any other library or function. I can't use MFC. But i feel MFC classes also internally dependent on WININET sdk only. Please help me...
Myself dot NET
February 26th, 2004, 03:28 AM
Originally posted by manish_birla
i'm writting a dll which is using wininet.dll. yeah i'm using wininet.lib in that dll. but while i'm unloading my dll it takes too long time. My dll has to loaded & unloaded explicitely.
I don't understand why you are implicitly linking to wininet.lib if you are going to explicitly load wininet.dll anyway? That is unnecessary.
Also, is this code from your DllMain function? I hope it's not.
manish_birla
February 26th, 2004, 04:40 AM
as i told my dll is explicitely loaded & unloaded. my dll is using wininet.dll. The problem is while i do freelibrary for my dll it's taking time. To trace out the cause of problem i test it with wininet.dll which my dll is using. so when i unload my dll it might unload wininet dll also. as wininet dll is taking time in unloading in turn my dll also taking long time to unload.
while debugging i trace out the problem. so i wrote separate program to test behavior of wininet at run time. which i have pasted..
again i give u sequence of calling the api's in my dll...
InternetOpen
InternetOpenUrl
HttpQueryInfo
& than closing the handle got from api call InternetOpen & InternetOpenUrl.
While calling this api's r working fine but on unloading it's taking time. On win xp it's working fine.
My dll is using wininet.lib, it is not load it expliciltly. it's just sample program to trace out y my dll is taking too long time while unloading. if i solve out this problem, may be my dll will also unloaded fast.
It is part of big problem to trace out. anyway no where i'm loading or unloading or doing anything with wininet in dll main. In my dll DLL main is doing nothing as far wininet concern. in one function only i'm using wininet dll function to make https connection. my dll is using wininet.lib only but because of some reason my dll taking time to unload. the reason is wininet.lib. if i remove it done very fast.
when i test separately wininet.dll in separate program i found if don't call internetopenurl it unload fast & if i do call it , it takes long time to unload it.
now i think picture is very clear.
manish
usman999_1
February 26th, 2004, 04:48 AM
Hi Manish!
Well I dont know why ur getting this sortof behaviour. I have in my application need to get some data from the HTTPs server. My code looks somewhat like this (For Connecting
USMAN: thanks for piece of code but main problem is unloading of dll.
usman999_1
February 26th, 2004, 06:15 AM
Then i would say to post a demo project for the problem you are having.
Regards,
Usman.
mcpata
February 26th, 2004, 09:51 PM
Are you sure you have read ALL data before closing the handle and unloading the library? If not, you may need to wait until the TCP connection times out (FIN_WAIT2). This is neither the problem of HTTP / HTTPS protocol nor the WinInet SDK / API.
Indeed this is a normal behaviour of TCP based communication on most operating systems.
manish_birla
March 1st, 2004, 12:18 AM
How i can make sure weather there is pending data on socket or not. it's job of wininet sdk only.
But i feel there problem is sth else or may be it's bug in wininet sdk.
Myself dot NET
March 1st, 2004, 12:26 AM
As was mentioned, maybe you should post your project. I wouldn't jump to the conclusion that it is a bug with WinInet, because it seems you are the only one experiencing this problem. The more likely explanation is that it is a problem with your application.
manish_birla
March 1st, 2004, 02:18 AM
here is the sample project ...been attached with this mail.
fngood
November 12th, 2005, 01:37 PM
Not sure if this was ever resolved, but I had the exact same problem but under different conditions
Using wininet by including .lib in project
executing InternetOpen calls inside a thread
Had the same problem with FreeLibrary taking a while (20 seconds) then completing fine.
But get this: It only happened when the URL passed to InternetOpenUrl was of the following format: http://http://www.xyz.com
If the URL format was valid but the domain didn't exist, it still worked! I could only get it to happen when the two "http://" prefixes were included. This is clearly some kind of bug in wininet.
NoHero
November 13th, 2005, 08:30 AM
[ Moved Thread ]
codeguru.com
Copyright 2007 Jupitermedia Corporation All Rights Reserved.