title: Listen for UDP messages in Express
body: <p>I have a basic Node.js server using Express. It needs to be able to handle TCP messages as well as UDP messages. The TCP part is up and running great, but now I need to integrate a way to sniff out the UDP messages. I've tried adding a handler to the filter stack using a <code>dgram</code> socket, but it hasn't been successful.</p>
  
  <pre><code>const express = require('express');
  const dgram = require('dgram');
  
  // ...
  
  const app = express();
  const dgramSocket = dgram.createSocket('udp4');
  
  // ...
  
  app.use((req, res, next) =&gt; {
    dgramSocket.on('listening', () =&gt; {
      let addr = app.address();
      console.log(`Listening for UDP packets at ${addr.address}:${addr.port}`);
    });
  
    dgramSocket.on('error', (err) =&gt; {
      console.log(`UDP error: ${err.stack}`);
    });
  
    dgramSocket.on('message', (msg, rinfo) =&gt; {
      console.log(`Received UDP message`);
    });
  
    next();
  
  }
  
  // ...
  
  app.set('port', 8080);
  </code></pre>
  
  <p>When I run my server everything else works, but my <code>dgram</code> parts don't even say that they're listening. I'm not too familiar with Node and even less so with UDP, so I might be on the complete wrong track. Has anyone been able to integrate UDP messaging with an Express server?</p>