difference between socket and web server example
<p>Socket based example, taken from nodejs website</p>

<pre><code>var server = net.createServer((socket) =&gt; {
  socket.end('goodbye\n');
}).on('error', (err) =&gt; {
  // handle errors here
  throw err;
});

// grab a random port.
server.listen(() =&gt; {
  address = server.address();
  console.log('opened server on %j', address);
});
</code></pre>

<p>Web Server</p>

<pre><code>const http = require('http');

const hostname = '127.0.0.1';
const port = 3000;

const server = http.createServer((req, res) =&gt; {
  res.statusCode = 200;
  res.setHeader('Content-Type', 'text/plain');
  res.end('Hello World\n');
});

server.listen(port, hostname, () =&gt; {
  console.log(`Server running at http://${hostname}:${port}/`);
});
</code></pre>

<p>My question is what the difference between the two? Is Web Server something programmed on top of Socket example with additional features like request and response populated with different properties or they are different types of communication protocols? Is socket is what is working under the hood for the Web Server example?</p>