m***@gmail.com
2005-03-07 18:06:50 UTC
Hi all,
My question is about wininet and multithreading. It is not a general
question but a specific one.
I made research on the net but did not find any answers or solutions.
If this is a well known problem with posted solutions my apologies. So,
here is the problem:
Programming language: C++
Compiler/linker : VC .Net
OS : Windows XP latest Service Pack
Objective is to grab images from several IP Cameras using HTTP API
specs. of the cameras by polling. Basically these are simple HTTP
requests.
I encapsulate the HTTP communication routines in a class. This class
also has a function entry point for multithreading: a static class
function which is passed to beginthread(), calling a regular class
method where all necessary work is done.
For each camera there is an instance of this class and of course a
separate thread. The thread simply uses InternetOpenUrl() to make the
HTTP request (asking for image data) which then is read using
InternetReadFile(). I believe I am also making necessary error
checkings in between. The calls to InternetOpenUrl() and
InternetReadFile() are in a loop which terminates when a flag is set to
terminate the thread. So far so good.
The weird thing is, when more than one thread (or cameras) are working,
after some time (1-2 minutes), I start getting 12029 errors. My code
handles these errors by just skipping that connection attempt but the
error frequency becomes very high and at the end makes the process
unstable. When there is only one thread running there are no problems.
It seems to me like some kind of buffer is filled after sometime and
then connection attempts start to fail. Or, it may also be a
multithreading synchronization problem.
Do you have any idea ? Is there anyone else having similar problems ?
Do you think I should switch to winhttp (which I really don't to want
due to all Unicode conversions I have to make) ?
Thank you for your help,
Murat
My question is about wininet and multithreading. It is not a general
question but a specific one.
I made research on the net but did not find any answers or solutions.
If this is a well known problem with posted solutions my apologies. So,
here is the problem:
Programming language: C++
Compiler/linker : VC .Net
OS : Windows XP latest Service Pack
Objective is to grab images from several IP Cameras using HTTP API
specs. of the cameras by polling. Basically these are simple HTTP
requests.
I encapsulate the HTTP communication routines in a class. This class
also has a function entry point for multithreading: a static class
function which is passed to beginthread(), calling a regular class
method where all necessary work is done.
For each camera there is an instance of this class and of course a
separate thread. The thread simply uses InternetOpenUrl() to make the
HTTP request (asking for image data) which then is read using
InternetReadFile(). I believe I am also making necessary error
checkings in between. The calls to InternetOpenUrl() and
InternetReadFile() are in a loop which terminates when a flag is set to
terminate the thread. So far so good.
The weird thing is, when more than one thread (or cameras) are working,
after some time (1-2 minutes), I start getting 12029 errors. My code
handles these errors by just skipping that connection attempt but the
error frequency becomes very high and at the end makes the process
unstable. When there is only one thread running there are no problems.
It seems to me like some kind of buffer is filled after sometime and
then connection attempts start to fail. Or, it may also be a
multithreading synchronization problem.
Do you have any idea ? Is there anyone else having similar problems ?
Do you think I should switch to winhttp (which I really don't to want
due to all Unicode conversions I have to make) ?
Thank you for your help,
Murat