I’m trying to use an httpSocket to download multiple images from the web (Gravatar images).
The httpsocket.get(url) is in a tight loop as it runs through the list of emails.
But the httpsocket.pageReceived event only fires once with one returned image.
Do I need to create a new httpSocket / AddHander combination for each image that I want to download?
I would highly recommend using some queue system to enqueue URLs you to download.
Than use HTTPSocket asynchronously to get them and keep track of parallel downloads.
And I also recommend one instance per download.
I will rush in like a fool here.
I have only ever used sockets ( now TCPsockets ) never http ones.
Should you not be sending the next “GET” after the first is finished and returned what you want, instead of tightly pumping out requests? Or do I misunderstand?
Also, sockets seem to need a bit of time to go powder their noses after being used, and it is often better to trash a socket ( nil it ) and make another one, or unexpected stuff happens.
Thanks.
I’ve now added an array of httpSockets - new one added each time a new URL is requested.
Each socket is run asynchronously.
When the pageReceived event is fired I remove the associated AddHandler then remove the httpSocket from the array.
I guess I also ought to do the same with some kind of timer to ensure that they all get cleared eventually, even if no response from the web.
Seems to work fine now.