[quote=380983:@Kimball Larsen]Hi Ian,
First off, I pointed you to the incorrect documentation for ReceiveProgress - I accidentally sent you to the classic framework docs, not the new framework docs. You mentioned above that you are using a xojo.net.httpsocket, which is in the new framework. The docs for ReceiveProgress there are here: http://developer.xojo.com/xojo-net-httpsocket$ReceiveProgress
However, they are so similar that the docs are not substantially different. I just wanted to clear that up.
Secondly, the -1 is concerning… but there are at least a few different reasons why it is appearing. My first guess is that the api you are communicating with is not sending the correct headers back in the response to indicate the total size of the response, so the socket has no way of knowing. To verify this, you could use another tool such as Rested (on the mac - I’m sure there are others available on Windows but you’ll have to hit up google) to manually hit the API endpoints and very carefully inspect the traffic (headers and content).
Thirdly: if your ultimate goal is to make sure that you don’t try to re-use a socket that is currently in the process of receiving data, you’ll probably need to build a state machine class that wraps the socket. When the socket makes a request, it enters the “busy” state. When the PageReceived event fires in the socket, it enters the “idle” state, etc.
I have a few other questions that may be helpful as well:
Have you tried checking the PageReceived event to see if it is firing at the conclusion of your download?
How large is the data (in bytes) you are expecting in the responses? 100 bytes? 1000 bytes? 200 Megabytes?
What is the webservice api you are using? Is it something I could try to mock up a quick example for? I may have some time later today I could slap something together.
Good luck![/quote]
Thanks. The state machine idea feels right. I’ll think a bit more about how to do this.
I’m using the PageReceived event to grab the data that comes back.
Size of data is about 50K, so we are not talking about massive data packages at all!
The webservice is a private one for one of my clients I’m afraid, so it’s not feasible for me to point you to the details. Thank you for the offer anyway; that is very generous.
Regarding the -1 thing, I use Paw on my Mac, so I will analyse the data coming back from that.
In case it’s of interest, here is a screenshot from an example I put together today. I hit the “Get projects for server” button and the result comes back in less than a second. I used the ReceiveProgress event to add rows to the two list boxes. I always get the 200 status code, and the textarea has the json package that constitutes the result.
Thanks for your continued help with this - much appreciated.