title: socket.io clientside connecting with 'http://localhost' does not work?
body: <p>I run a server with node.js &amp; socket.io on MacOS to serve different clients in a local network.
  As far as i understand, the socket.io library has to be loaded first on the clientside as stated in the documention <a href="https://socket.io/docs/" rel="nofollow noreferrer">https://socket.io/docs/</a>:</p>
  
  <pre><code>&lt;script src="/socket.io/socket.io.js"&gt;&lt;/script&gt;
  &lt;script&gt;
     var socket = io('http://localhost');
  …
  &lt;/script&gt;
  </code></pre>
  
  <p>This seems to be only to a proposing template, because this does not work at all (or maybe i did something wrong?)?</p>
  
  <p>So i changed "localhost" to the actual IP address+port of my server (192.168.178.2:3000) and now everything just works fine, especially with different client platforms like MacOS, iOS, Android &amp; Windows (as wanted!).</p>
  
  <p>The problem is, that i want to use the server alternately in different local nets and therefore with changing IP-adresses. But to specify the server address always in that "hardwired" manner manually (!) is very cumbersome and seems not practically. There must be a better solution!</p>
  
  <p>So i did some experiments with logical names.
  First i added the port:</p>
  
  <pre><code>var socket = io('http://localhost:3000');
  </code></pre>
  
  <p>This works (at least) but ONLY on the mac itself, where also the server runs!?</p>
  
  <p>Then a little more specific:</p>
  
  <pre><code>var socket = io('http://theNameOfMyMac.local:3000');
  </code></pre>
  
  <p>Voila, this now works also with external devices! Great!
  But wait, only with MacOS and iOS, not Windows and Android devices. 
  Too bad, because this would have been a practical solution to my problem!
  So, i am back at my initial solution where i always have to specify the actual IP address in the HTML file. Nothing else seems to help?</p>
  
  <p>Can someone explain to me why this behaves like this and what could possibly be a solution?
  Maybe the HTML code could get the (calling!) server address automatically in the HTML file itself? But how?</p>
  
  <p>By the way, should there not be a difference between:</p>
  
  <pre><code>var socket = io('http://192.168.178.2:3000');
  and
  var socket = io.connect('http://192.168.178.2:3000');
  </code></pre>
  
  <p>Both work without a noticeable difference!?</p>