title: How to us app.post event (from express) to write a message to clients with socket.write?
body: <p>I am trying to send a message from a input field in a html form to all clients connected to the server when one of the clients posts something in the input field (textbox). I want to use the socket.write function because I have a raw TCP client connected to the server. 
  I tried to use the Express library with the Post event because I want that kind of behaviour but can't use socket e.g. <code>socket.write</code> function inside of the <code>app.post</code> function.</p>
  
  <p>Here is what I currently have on the server side:</p>
  
  <pre><code>var express = require('express');
  var bodyParser = require('body-parser');
  var app     = express();
  var net = require('net');
  
  var server = net.createServer(function (socket) {
  socket.write(' + req.body.name + ');
  socket.pipe(socket);
  });
  
  app.get('/', function(req, res){
  res.sendfile('index.html');
  });
  
  app.post('/myaction', function(req, res)  {
  res.send('You sent the name "' + req.body.name + '".');
  //How to do this here?? 
  server.socket.write(' + req.body.name + ')
  socket.end();
  
  });
  
  app.listen(3000, function() {
  console.log('Server running at http://127.0.0.1:3000/');
  });
  //Thought of using a different server port for the raw TCP device
  server.listen(2000, '127.0.0.1');
  </code></pre>
  
  <p>And a html form on the client side:</p>
  
  <pre><code>&lt;!DOCTYPE html&gt;
  &lt;html&gt;
  &lt;head&gt;
  &lt;meta charset="utf-8" /&gt;
  &lt;title&gt;Form&lt;/title&gt;
  &lt;/head&gt;
  &lt;body&gt;
  &lt;div id="contact"&gt;
  &lt;h1&gt;Send an email&lt;/h1&gt;
  &lt;form action="http://127.0.0.1:3000/myaction" method="post"&gt;
      &lt;fieldset&gt;
          &lt;label for="name"&gt;Name:&lt;/label&gt;
          &lt;input type="text" id="name" name="name" placeholder="Your      name" /&gt;
  
          &lt;label for="email"&gt;Surname:&lt;/label&gt;
          &lt;input type="text" id="surname" placeholder="Your surname" /&gt;
  
          &lt;input type="submit" value="Send" /&gt;
  
      &lt;/fieldset&gt;
  &lt;/form&gt;
  &lt;/div&gt;
  &lt;/body&gt;
  &lt;/html&gt;
  </code></pre>
  
  <p>Is there a way to do the <code>socket.write</code> on the <code>app.post event</code>. And can the name from the input field be sent using <code>socket.write</code>.</p>
  
  <p>Sorry if i am missing something, I am new to this kind of programming.</p>