Search code examples
node.jssocketstcpappfog

Node.js TCP Socket Server on AppFog


Given the following simple TCP socket server running on AppFog that echoes back whatever the client sends.

var net = require('net');

var server = net.createServer(function (socket) {
  socket.write('Echo server\r\n');
  socket.pipe(socket);
});

var port = process.env.VCAP_APP_PORT || 80;
server.listen(port);
console.log('Server running at ' + port);

I can't seem to connect to the server at all. It works fine on my local development machine.

Does AppFog support what I am trying to do at all? I'm relatively new to Node.js so I can't say for sure the code is correct.


Solution

  • The short answer is no. The long answer is in this other StakOverflow question: Node.js TCP Socket Server on the Cloud [Heroku/AppFog]