title: Is there a way to trigger the socket.io connection event from NodeJS?
body: <p>I'm trying some things with socket.io on NodeJS and I can't figure out how to trigger the the socket (only) from NodeJS.</p>
  
  <p>Till now I was using socket.io by calling it from the front end but I wonder if is it possible to do the same thing I did on the front end but this time on the nodeJS part(server side).</p>
  
  <p>My guess is it's not possible because is required a kind of connection(I like to call it a TCP connection,but I'm not sure if that's true or not) and without a second participant in the connection the socket won't work.That's my guess.</p>
  
  <p>So what I'm doing now is : </p>
  
  <p>app.js(server file)</p>
  
  <pre><code> ...
   const ioLib = require('./path/io.js')(io);
   ...
   ...
   ...
  </code></pre>
  
  <p>path/io.js(socket file)</p>
  
  <pre><code> module.exports = function(io){
  
   io.on('connection', async function(socket) {
   console.log('socket talks : a user connected');
   ...
   ...
   });
  
   module.exports.io = io;
  
   }
  </code></pre>
  
  <p>And from an file.ejs file I do :</p>
  
  <pre><code>var socket = io("url");
  </code></pre>
  
  <p>So with this,let's call it schema,I do the following :</p>
  
  <p>When I access that webpage the 'connection' event is triggered in the sockets.
  My question is,and I'm trying to formulate it as simple as I can :
  How can I do the same but without a webpage?Is it possible to trigger the sockets inside the NodeJS?</p>
  
  <p>What do you think?</p>