<p>Trying to honor a feature request from our customers, I'd like that my application, when Internet is available, check on our website if a new version is available.</p>

<p>The problem is that I have no idea about what have to be done on the server side.</p>

<p>I can imagine that my application (developped in C++ using Qt) has to send a request (HTTP ?) to the server, but what is going to respond to this request ? In order to go through firewalls, I guess I'll have to use port 80 ? Is this correct ?</p>

<p>Or, for such a feature, do I have to ask our network admin to open a specific port number through which I'll communicate ?</p>

<hr>

<p>@<a href="https://stackoverflow.com/questions/56391/automatically-checking-for-a-new-version-of-my-application/56418#56418">pilif</a> : thanks for your detailed answer. There is still something which is unclear for me :</p>

<blockquote>
  <p>like</p>
  
  <p><code>http://www.example.com/update?version=1.2.4</code></p>
  
  <p>Then you can return what ever you want, probably also the download-URL of the installer of the new version.</p>
</blockquote>

<p>How do I return something ? Will it be a php or asp page (I know nothing about PHP nor ASP, I have to confess) ? How can I decode the <code>?version=1.2.4</code> part in order to return something accordingly ?</p>

[{'answer_id': 56404, 'author': 'Community', 'author_id': -1, 'author_profile': 'https://Stackoverflow.com/users/-1', 'pm_score': 0, 'selected': False, 'text': '<p>The simplest way to make this happen is to fire an HTTP request using a library like <a href="http://curl.haxx.se/libcurl/" rel="nofollow noreferrer">libcurl</a> and make it download an ini or xml file which contains the online version and where a new version would be available online.</p>\n\n<p>After parsing the xml file you can determine if a new version is needed and download the new version with libcurl and install it.</p>\n'}, {'answer_id': 56405, 'author': 'wvdschel', 'author_id': 2018, 'author_profile': 'https://Stackoverflow.com/users/2018', 'pm_score': 0, 'selected': False, 'text': '<p>Just put an (XML) file on your server with the version number of the latest version, and a URL to the download the new version from. Your application can then request the XML file, look if the version differs from its own, and take action accordingly.</p>\n'}, {'answer_id': 56407, 'author': 'Marcin Gil', 'author_id': 5731, 'author_profile': 'https://Stackoverflow.com/users/5731', 'pm_score': 0, 'selected': False, 'text': '<p>I think that simple XML file on the server would be sufficient for version checking only purposes.</p>\n\n<p>You would need then only an ftp account on your server and build system that is able to send a file via ftp after it has built a new version. That build system could even put installation files/zip on your website directly!</p>\n'}, {'answer_id': 56408, 'author': 'Anthony Williams', 'author_id': 5597, 'author_profile': 'https://Stackoverflow.com/users/5597', 'pm_score': 1, 'selected': False, 'text': '<p>On the server you could just have a simple file "latestversion.txt" which contains the version number (and maybe download URL) of the latest version. The client then just needs to read this file using a simple HTTP request (yes, to port 80) to retrieve <a href="http://your.web.site/latestversion.txt" rel="nofollow noreferrer">http://your.web.site/latestversion.txt</a>, which you can then parse to get the version number. This way you don\'t need any fancy server code --- you just need to add a simple file to your existing website.</p>\n'}, {'answer_id': 56412, 'author': 'Alex Duggleby', 'author_id': 5790, 'author_profile': 'https://Stackoverflow.com/users/5790', 'pm_score': 0, 'selected': False, 'text': "<p>If you want to keep it really basic, simply upload a version.txt to a webserver, that contains an integer version number. Download that check against the latest version.txt you downloaded and then just download the msi or setup package and run it.</p>\n\n<p>More advanced versions would be to use rss, xml or similar. It would be best to use a third-party library to parse the rss and you could include information that is displayed to your user about changes if you wish to do so.</p>\n\n<p>Basically you just need simple download functionality.</p>\n\n<p>Both these solutions will only require you to access port 80 outgoing from the client side. This should normally not require any changes to firewalls or networking (on the client side) and you simply need to have a internet facing web server (web hosting, colocation or your own server - all would work here).</p>\n\n<p>There are a couple of commercial auto-update solutions available. I'll leave the recommendations for those to others answerers, because I only have experience on the .net side with Click-Once and Updater Application Block (the latter is not continued any more).</p>\n"}, {'answer_id': 56418, 'author': 'pilif', 'author_id': 5083, 'author_profile': 'https://Stackoverflow.com/users/5083', 'pm_score': 6, 'selected': True, 'text': "<p>I would absolutely recommend to just do a plain HTTP request to your website. Everything else is bound to fail.</p>\n\n<p>I'd make a HTTP GET request to a certain page on your site containing the version of the local application.</p>\n\n<p>like</p>\n\n<pre><code>http://www.example.com/update?version=1.2.4\n</code></pre>\n\n<p>Then you can return what ever you want, probably also the download-URL of the installer of the new version. </p>\n\n<p>Why not just put a static file with the latest version to the server and let the client decide? Because you may want (or need) to have control over the process. Maybe 1.2 won't be compatible with the server in the future, so you want the server to force the update to 1.3, but the update from 1.2.4 to 1.2.6 could be uncritical, so you might want to present the client with an optional update.</p>\n\n<p>Or you want to have a breakdown over the installed base.</p>\n\n<p>Or whatever. Usually, I've learned it's best to keep as much intelligence on the server, because the server is what you have ultimate control over.</p>\n\n<p>Speaking here with a bit of experience in the field, here's a small preview of what can (and will - trust me) go wrong:</p>\n\n<ul>\n<li>Your Application will be prevented from making HTTP-Requests by the various Personal Firewall applications out there.</li>\n<li>A considerable percentage of users won't have the needed permissions to actually get the update process going.</li>\n<li>Even if your users have allowed the old version past their personal firewall, said tool will complain because the .EXE has changed and will recommend the user not to allow the new exe to connect (users usually comply with the wishes of their security tool here).</li>\n<li>In managed environments, you'll be shot and hanged (not necessarily in that order) for loading executable content from the web and then actually executing it.</li>\n</ul>\n\n<p>So to keep the damage as low as possible, </p>\n\n<ul>\n<li>fail silently when you can't connect to the update server</li>\n<li>before updating, make sure that you have write-permission to the install directory and warn the user if you do not, or just don't update at all.</li>\n<li>Provide a way for administrators to turn the auto-update off.</li>\n</ul>\n\n<p>It's no fun to do what you are about to do - especially when you deal with non technically inclined users as I had to numerous times.</p>\n"}, {'answer_id': 56440, 'author': 'Martin Marconcini', 'author_id': 2684, 'author_profile': 'https://Stackoverflow.com/users/2684', 'pm_score': 4, 'selected': False, 'text': '<p>Pilif answer was good, and I have lots of experience with this too, but I\'d like to add something more:</p>\n\n<p>Remember that if you start yourapp.exe, then the "updater" will try to overwrite yourapp.exe with the newest version. Depending upon your operating system and programming environment (you\'ve mentioned C++/QT, I have no experience with those), you will <strong>not</strong> be able to overwrite <em>yourapp.exe</em> because it will be in use. </p>\n\n<p>What I have done is create a launcher. I have a MyAppLauncher.exe that uses a config file (xml, very simple) to launch the "real exe". Should a new version exist, the Launcher can update the "real exe" because it\'s not in use, and then relaunch the new version.</p>\n\n<p>Just keep that in mind and you\'ll be safe. </p>\n'}, {'answer_id': 56454, 'author': 'pilif', 'author_id': 5083, 'author_profile': 'https://Stackoverflow.com/users/5083', 'pm_score': 3, 'selected': False, 'text': '<p>Martin, </p>\n\n<p>you are absolutely right of course. But I would deliver the launcher with the installer. Or just download the installer, launch it and quit myself as soon as possible. The reason is bugs in the launcher. You would never, ever, want to be dependent on a component you cannot update (or forget to include in the initial drop).</p>\n\n<p>So the payload I distribute with the updating process of my application is just the standard installer, but devoid of any significant UI. Once the client has checked that the installer has a chance of running successfully and once it has downloaded the updater, it runs that and quits itself.</p>\n\n<p>The updater than runs, installs its payload into the original installation directory and restarts the (hopefully updated) application.</p>\n\n<p>Still: The process is hairy and you better think twice before implementing an Auto Update functionality on the Windows Platform when your application has a wide focus of usage.</p>\n'}, {'answer_id': 56532, 'author': 'robsoft', 'author_id': 3897, 'author_profile': 'https://Stackoverflow.com/users/3897', 'pm_score': 2, 'selected': False, 'text': "<p>I would agree with @Martin and @Pilif's answer, but add;</p>\n\n<p>Consider allowing your end-users to decide if they want to actually install the update there and then, or delay the installation of the update until they've finished using the program. </p>\n\n<p>I don't know the purpose/function of your app but many applications are launched when the user needs to do something specific there and then - nothing more annoying than launching an app and then being told it's found a new version, and you having to wait for it to download, shut down the app and relaunch itself. If your program has other resources that might be updated (reference files, databases etc) the problem gets worse.</p>\n\n<p>We had an EPOS system running in about 400 shops, and initially we thought it would be great to have the program spot updates and download them (using a file containing a version number very similar to the suggestions you have above)... great idea. Until all of the shops started up their systems at around the same time (8:45-8:50am), and our server was hit serving a 20+Mb download to 400 remote servers, which would then update the local software and cause a restart. Chaos - with nobody able to trade for about 10 minutes.</p>\n\n<p>Needless to say that this caused us to subsequently turn off the 'check for updates' feature and redesign it to allow the shops to 'delay' the update until later in the day. :-)</p>\n\n<p>EDIT: And if anyone from ADOBE is reading - for god's sake why does the damn acrobat reader insist on trying to download updates and crap when I just want to fire-it-up to read a document? Isn't it slow enough at starting, and bloated enough, as it is, without wasting a further 20-30 seconds of my life looking for updates every time I want to read a PDF?<br>\n<b>DONT THEY USE THEIR OWN SOFTWARE??!!!</b>  :-)</p>\n"}, {'answer_id': 56593, 'author': 'Peter Turner', 'author_id': 1765, 'author_profile': 'https://Stackoverflow.com/users/1765', 'pm_score': 1, 'selected': False, 'text': '<p>if you keep your files in the update directory on example.com, this PHP script should download them for you given the request previously mentioned.  (your update would be yourprogram.1.2.4.exe</p>\n\n<pre><code>$version = $_GET[\'version\'];    \n$filename = "yourprogram" . $version . ".exe";\n$filesize = filesize($filename);\nheader("Pragma: public");\nheader("Expires: 0");\nheader("Cache-Control: post-check=0, pre-check=0");\nheader("Content-type: application-download");\nheader(\'Content-Length: \' . $filesize);\nheader(\'Content-Disposition: attachment; filename="\' . basename($filename).\'"\');\nheader("Content-Transfer-Encoding: binary");\n</code></pre>\n\n<p>This makes your web browser think it\'s downloading an application.  </p>\n'}, {'answer_id': 56997, 'author': 'pilif', 'author_id': 5083, 'author_profile': 'https://Stackoverflow.com/users/5083', 'pm_score': 3, 'selected': False, 'text': '<p>in php, the thing is easy:</p>\n\n<pre><code>&lt;?php\n    if (version_compare($_GET[\'version\'], "1.4.0") &lt; 0){\n        echo "http://www.example.com/update.exe";\n    }else{\n        echo "no update";\n    }\n?&gt;\n</code></pre>\n\n<p>if course you could extend this so the currently available version isn\'t hard-coded inside the script, but this is just about illustrating the point.</p>\n\n<p>In your application you would have this pseudo code:</p>\n\n<pre><code>result = makeHTTPRequest("http://www.example.com/update?version=" + getExeVersion());\nif result != "no update" then\n    updater = downloadUpdater(result);\n    ShellExecute(updater);\n    ExitApplication;\nend;\n</code></pre>\n\n<p>Feel free to extend the "protocol" by specifying something the PHP script could return to tell the client whether it\'s an important, mandatory update or not. </p>\n\n<p>Or you can add some text to display to the user - maybe containing some information about what\'s changed.</p>\n\n<p>Your possibilities are quite limitless.</p>\n'}, {'answer_id': 60572, 'author': 'Andy Brice', 'author_id': 455552, 'author_profile': 'https://Stackoverflow.com/users/455552', 'pm_score': 2, 'selected': False, 'text': '<p>My Qt app just uses QHttp to read tiny XML file off my website that contains the latest version number. If this is greater than the current version number it gives the option to go to the download page. Very simple. Works fine.</p>\n'}]
['https://Stackoverflow.com/questions/56391', 'https://Stackoverflow.com', 'https://Stackoverflow.com/users/2796/']