RTC Forums

Subscription => Support => Topic started by: jonb2 on February 13, 2012, 06:15:19 PM



Title: WinHTTP bug ?
Post by: jonb2 on February 13, 2012, 06:15:19 PM
Hi D

I have just come across a problem which has been driving me mad.

I notice that with WinHTTP enabled, that above a response size of approx 32k, the data is truncated. Wininet is fine with the same request.

Please can you have a look. I might be wrong.

Cheers

Jo


Title: Re: WinHTTP bug ?
Post by: D.Tkalcec (RTC) on February 13, 2012, 07:20:38 PM
Works fine for me. I've just downloaded the latest RealThinClient SDK package from this Server (the file is 2.4 MB in size) using the File_Client demo with "WinHTTP" checked. Is it possible that you aren't handling the "OnDataReceived" event correctly? If you can't get it working, I will need to see the source code you are using.

Best Regards,
Danijel Tkalcec


Title: Re: WinHTTP bug ?
Post by: jonb2 on February 13, 2012, 07:36:36 PM
Yes, you are correct. I just solved it by moving the read command to a if TRtcDataClient(Sender).Response.Done check.

Sorry about the false alarm. I am finding the sequence of threads and events quite hard to understand. It would be great if there was a sequence flow diagram of the events when threaded.

Also, I am unsure what the blocking option does to this event chain? As far as I can tell, it simply disallows any asynchronous actions. So should speed things up.

Thanks again for your quick response Danijel.

Jon

 


Title: Re: WinHTTP bug ?
Post by: D.Tkalcec (RTC) on February 13, 2012, 08:05:38 PM
All events from a single connection are always executed in the same sequence, regardless wether you are using threads or not.

I think what might be somewhat confusing, is that the OnDataReceived event will be fired immediately when the response starts coming in and again (and again, and ... ) as long as more data is arriving for that request/response sequence (and not only once for the complete request/response).

The same goes for sending data out. The "OnDataSent" event will be called every time all the prepared data from the sending buffer is sent, so you can split the sending process in as big or as little packets as you want.

As for the "blocking" property, it defines what kind of API will be used. On Windows, the RTC SDK supports asynchronous WinSock, blocking WinSock, blocking WinInet and blocking WinHTTP APIs. On MacOSX and iOS, the RTC SDK supports blocking BSD sockets as well as emulated non-blocking BSD sockets (using threads). And ... you can use them all with MultiThreaded=True, in which case all the events will be executed from background threads and your main thread won't be blocked even when using a blocking API.

For you, it should not matter much which API is being used if you implement your code correctly.

Best Regards,
Danijel Tkalcec


Title: Re: WinHTTP bug ?
Post by: jonb2 on February 15, 2012, 12:09:17 PM
Thanks again D  :)