Running a simple TCP server

43 views
Skip to first unread message

Jaap Karan Singh

unread,
Jul 13, 2012, 11:16:15 PM7/13/12
to node...@googlegroups.com
Hey guys, I am trying to run a basic TCP server which simply outputs data sent on both sides.  Can someone have a look at the code and tell me what I am doing wrong, I've tried a few different things but to no avail.

App details:


Corey Clark

unread,
Mar 14, 2013, 2:26:50 PM3/14/13
to node...@googlegroups.com
Jaap

I tried to do some work with TCP on nodester a while back, I eventually got it working but you have to change how you are doing the connections.

Since nodester uses subdomains to route traffic, you can not actually connect directly to your application instance via a TCP connection.  The subdomain data is lost (it is converted to the IP address of the nodester sever, where all apps are being hosted) and therefore nodester can not route the connection directly to your application.

The workaround is this... 

Have your TCP client send an a request to your app using HTTP protocol (REST api type stuff), this will allow its request to be sent directly to your app being hosted on nodester.  The request should have the IP address and port in which client wants to communicate.  The server can then take this information and then initiate a TCP connection with the client (Basically the client and server have to switch rolls).  Once the connection is accepted on the client, you can communicate back and forth with no problem.

In essence the client has to send the HTTP request, but then go into the sever mode where it starts listening for incoming connection request.  The app hosted on nodester now acts as a client, and send connections request to anyone who sends a request via HTTP... essentially making it a client that connects to multiple severs...

I am not sure how clear that explanation actually is... hopefully it will help you get everything up and running

Corey Clark
Twitter: @CoreyClarkPhD
Reply all
Reply to author
Forward
0 new messages