What's the best way to add secure Net Connections to a project?


#1

I wrote a little app that got featured on ProToolsExpert this past december, and part of what I had to figure out during development was how to talk to a webserver from within the app.   for OS X, I ended up adding a dependency on libcurl because OS X ships with CURL, so it was super easy to add it in.    However, now that I'm developing the windows side of things, LibCurl doesn't come on windows, and neither does OpenSSL, so my development of the windows version is severly delayed because of this.    Is there anything built into JUCE that does what LibCurl does but is cross-platform?    The URL class seemed to only be for downloading data via a url, not for transmitting data between an app and a server (both uploading and downloading).  Please advise if you have any tips or suggestions!


#2

You seem a bit confused.. If you're using HTTP/HTTPS then the URL class should do everything you need. It handles POST, which is how you upload data - sounds like you're unfamiliar with the HTTP protocol, so you should read up about that, perhaps.

If you need lower-level control of two-way streaming data, then again JUCE already has everything you should need - i.e. socket classes.


#3

my app uses libcurl to send POSTDATA to a php script, which sends back data to the app.   

Should I follow the model shown in this? 

https://github.com/julianstorer/JUCE/blob/f1ad44e2bfd49acd19800342e944aaec7a3c04dd/examples/Demo/Source/Demos/NetworkingDemo.cpp

The documentation for how to use these classes is a little light...   

I went with libcurl initially for this reason, because libcurl is really easy to work with, esp if you wrap it into a C++ class like this: http://dahu.co.uk/blog/?p=77 and there are thousands of examples of how to use libcurl, whereas there are next to none for using the URL, StreamingSocket or other networking-related classes in JUCE.  

 


#4

libcurl seems a bit complicated to me!

We tried to make the URL a no-brainer to use - you just create your URL, add any post-data, parameters, files etc with the URL::withXYZ() methods, then call one of its read methods to read the result. Maybe have a look at TracktionMarketplaceStatus::readReplyFromWebserver()


#5

Thanks, I'll check it out.

 

I think what threw me off about the URL class is that i don't associate URLs with transmitting data in both directions between an application and a server.   So, i never considered looking in the URL class for it for that ability.   The URL class appeared to only be for when I want to use Hyperlink Buttons of some kind, or include text links to web pages.    If the URL class had a name like "NetworkConnection", then I would have known to check it out further and see that it was exactly what I needed. 


#6

Jules - what happens if there are certificate errors on the SSL connections using the URL class?  Is there a defined behaviour? 


#7

Couldn't tell you offhand... probably depends on the underlying OS implementation..