<p dir="auto">Is Electron capable of hosting a socket IO web server? I am currently trying to connect to my local systems internal IP over my local network (using a port specified by the Socket.IO server javascript) and my connection is timing out.</p>
<p dir="auto">I've been tracking down a bug in a program that works in OSX but fails mysteriously in Windows. I've pared down a minimal repro case to the <code class="notranslate">net.createConnection</code> / <code class="notranslate">net.createServer</code> APIs w/ a named pipe failing when run in the main atom process.</p>
<p dir="auto">If you specify <code class="notranslate">ATOM_SHELL_INTERNAL_RUN_AS_NODE=1</code> for both ends of the test it will function as you'd expect. If either one (or both) are <code class="notranslate">ATOM_SHELL_INTERNAL_RUN_AS_NODE=0</code>, the repro will hang in the middle of the test and fail to continue the ping/pong cycle.</p>
<p dir="auto">Reproduction steps (tested on Win7/32 w/electron-v0.28.0-win32-ia32):</p>
<ul dir="auto">
<li>Save the snippet below as <code class="notranslate">repro.js</code></li>
<li>Open two Windows command consoles</li>
<li>In the first one, run <code class="notranslate">electron.exe repro.js</code></li>
<li>In the second one, run <code class="notranslate">electron.exe repro.js client</code></li>
</ul>
<p dir="auto">What happens:</p>
<ul dir="auto">
<li>The ping/pong only runs a few cycles back and forth, then stops. It may occasionally continue after a pause of 30-60s.<br>
<a target="_blank" rel="noopener noreferrer nofollow" href="https://cloud.githubusercontent.com/assets/512240/8146764/5a48d748-1208-11e5-908e-c538c3f80121.png"><img src="https://cloud.githubusercontent.com/assets/512240/8146764/5a48d748-1208-11e5-908e-c538c3f80121.png" alt="screen shot 2015-06-13 at 8 10 06 pm" style="max-width: 100%;"></a></li>
</ul>
<p dir="auto">What I expect to happen:</p>
<ul dir="auto">
<li>The ping/pong continues indefinitely<br>
<a target="_blank" rel="noopener noreferrer nofollow" href="https://cloud.githubusercontent.com/assets/512240/8146766/6538da86-1208-11e5-8c66-729e258ea577.png"><img src="https://cloud.githubusercontent.com/assets/512240/8146766/6538da86-1208-11e5-8c66-729e258ea577.png" alt="screen shot 2015-06-13 at 8 10 43 pm" style="max-width: 100%;"></a></li>
</ul>
<div class="snippet-clipboard-content notranslate position-relative overflow-auto" data-snippet-clipboard-copy-content="var net = require('net');

var addr = '\\\\?\\pipe\\testpipe';

var counter = 0;

if (process.argv[2] == 'client') {
    var client = net.createConnection({ path: addr }, function() {
        console.log(&quot;Connected to named pipe as client&quot;);
        client.on('data', function(data) {
            console.log(&quot;rec'd: &quot; + data);
            setTimeout(function() {
                client.write(&quot;ping &quot; + counter++);
            }, 500);
        });

        client.write('ping!');
    }.bind(this));
} else {
    net.createServer(function(client) {
        console.log(&quot;Connected to named pipe as server&quot;);
        client.on('data', function(data) {
            console.log(&quot;rec'd: &quot; + data);
            setTimeout(function() {
                client.write(&quot;pong &quot; + counter++);
            }, 500);
        });
    }.bind(this)).listen(addr);
}"><pre class="notranslate"><code class="notranslate">var net = require('net');

var addr = '\\\\?\\pipe\\testpipe';

var counter = 0;

if (process.argv[2] == 'client') {
    var client = net.createConnection({ path: addr }, function() {
        console.log("Connected to named pipe as client");
        client.on('data', function(data) {
            console.log("rec'd: " + data);
            setTimeout(function() {
                client.write("ping " + counter++);
            }, 500);
        });

        client.write('ping!');
    }.bind(this));
} else {
    net.createServer(function(client) {
        console.log("Connected to named pipe as server");
        client.on('data', function(data) {
            console.log("rec'd: " + data);
            setTimeout(function() {
                client.write("pong " + counter++);
            }, 500);
        });
    }.bind(this)).listen(addr);
}
</code></pre></div>