-
Notifications
You must be signed in to change notification settings - Fork 13
using curl
Use multi-interface and share-interface to utilize all CURL benefits. The only multi-interface of the CURL is asynchronous and allows to reuse connections. The only share-interface allows to share cookies and DNS entries.
Set the CURLMOPT_MAXCONNECTS option explicitly for the multi-interface. Note that the only 32 sockets are allowed to be used under AirplaySDK. Note that 2 sockets are used per connection. Note that other parts of your application may use sockets also for other needs. Note that this option doesn't restrict total connections number, but restricts only number of connections to leave them open after all jobs are done by the multi-interface.
Don't push all requests into the multi-interface, it leads to opening connections immediately, but organize some kind of queue instead. You can control how many jobs (easy-interface handles) are running right now - and therefore how many connections are busy - using return values of the curl_multi_perform() call. Use this value to restrict total number of jobs running simultaneously by the multi-interface.
The CURL proceeds socket errors perfectly, and your application will work even without these options, but lot of socket errors will appear and overall perfomance of the appliation will degrade.
Don't forget to call curl_multi_perform() periodically somewhere in your application main circle to allow CURL to do it's work. Note that you can use socket interface to check, whether the CURL is really having the job to be processed. The last is not necessary, thruough.
You can use (and this is the only way to do this job) curl_multi_info_read() call to get errors on the asynchronous queries. Don't forget about freeing resources allocated by your application and the CURL in both, error and success, cases of the query result.
Look to the provided example to see how to organize a queue utilizing all options described here.
If you think that found an error in the porting package, try to extract the code causing the error, to the separate, platform-independent source file, and try your code to be evaluated on the Marmalade/AirplaySDK simulator, and after it, on the Windows, Linux, FreeBSD or other "big" platform supported by the CURL. Use the CURL library version exactly the same as the port uses. If the problem appears on the simulator, but doesn't appear on the "big" platform, it really looks like caused by the port. Feel free to report it directly here, applying your code case.
If you think that found an error in the CURL library, try to extract the code causing the error, to the separate, platform-independent source file, and try your code to be evaluated on the Windows, Linux, FreeBSD or other "big" platform supported by the CURL. If the problem still appears, try to repeat the problem with the last stable version of the CURL. If the problem still appears, try to repeat the problem with the development trunk of the CURL. If the problem still appears, report it to the CURL team.
If you having a problem and don't know whether it is caused by port, or the CURL library, or your mind, reread previous two paragraphs.