title: Deploying a node.js TCP server on heroku
body: <p>I have created a TCP server that receives messages from a client(using TCP Client android app for testing purposes) using node.js. Is it possible to deploy this on heroku? 
  Here is the code</p>
  
  <pre><code>var http = require('http')
  var express = require('express')
  var app = module.exports = express.createServer();
  var net = require('net')
  var port = process.env.PORT || 5000
  var routes = require('./routes')
  
  app.configure(function(){
    app.set('views', __dirname + '/views');
    app.set('view engine', 'jade');
    app.set('view options', {layout:false, pretty:true});
    app.use(express.bodyParser());
    app.use(express.methodOverride());
    app.use(app.router);
    app.use(express.static(__dirname + '/public'));
  });
  
  app.configure('development', function(){
    app.use(express.errorHandler({ dumpExceptions: true, showStack: true })); 
  });
  
  app.configure('production', function(){
    app.use(express.errorHandler()); 
  });
  
  //ROUTES
  
  app.get('/',routes.index);
  
  var mainserver = net.createServer(function(socket) {
      console.log('connected');
      socket.on('data',function(data){
      console.log(data.toString());
      io.sockets.emit('dummy',data.toString());
      });
  
      });
  
  mainserver.listen(1337, '192.168.1.108');
  
  var io = require('socket.io').listen(app);
  app.listen(port);
  </code></pre>
  
  <p>As you can see, I send tcp messages to port 1337 and an IP address which is assigned by router. </p>
  
  <p>When i type localhost:5000 on my browser I get an html page which just console logs the message that server recieves from app(and later sends it to client using socket.io).</p>
  
  <p>There are two ports being used here.</p>
  
  <p>If this were to be deployed on heroku, how to replace the port numbers? Also how to replace the IP address?</p>
  
  <p>Any help is appreciated</p>