Your server doesn't need to call net.connect() to connect back to the
client. You already have the connection with the "client" object, so you
can just call client.write() directly in the "data" event callback function.

On Wed, Jun 20, 2012 at 8:45 AM, Ben Noordhuis <[email protected]> wrote:

> On Wed, Jun 20, 2012 at 5:27 PM, Fabian Korak <[email protected]>
> wrote:
> > Hello, sorry for the double-post, google-mail interface decided to post
> > before I was finished...
> >
> > I'm currently working on an implementation of the echo-algorithm in
> > Node.js. I currently have code like this(a lot snipped obviously):
> > *
> > Initial Node:
> > *var own_port = 33333;
> > var start_port = 22222;
> > var sendNode = net.connect(start_port,function(){
> >             sendNode.write('info');
> >         })*
> > *//and typical listening code for listening on own_port
> > *Recieving Node:*
> > var own_port = 22222;
> > var back_port;
> >
> > var nodeServer = net.createServer();
> > nodeServer.on('connection', function(client)
> >     {
> >     client.on('data',function(data)
> >     {
> >     back_port = client.remotePort;
> >     var sendNode = net.connect(back_port,function(){
> >                         client.write('info');
> >                     })
> >
> > }
> >
> > nodeServer.listen(own_port);
> > As some of you now may have noticed is that node does not send on the
> same
> > port it listens. Is there any way to specify over which port
> > 'client.write()' sends, and if not, any alternatives or plans to add
> that?
>
> No and no. No offense but your question doesn't make sense in the
> context of the TCP protocol. TCP is always connection-oriented.
>
> --
> Job Board: http://jobs.nodejs.org/
> Posting guidelines:
> https://github.com/joyent/node/wiki/Mailing-List-Posting-Guidelines
> You received this message because you are subscribed to the Google
> Groups "nodejs" group.
> To post to this group, send email to [email protected]
> To unsubscribe from this group, send email to
> [email protected]
> For more options, visit this group at
> http://groups.google.com/group/nodejs?hl=en?hl=en
>

-- 
Job Board: http://jobs.nodejs.org/
Posting guidelines: 
https://github.com/joyent/node/wiki/Mailing-List-Posting-Guidelines
You received this message because you are subscribed to the Google
Groups "nodejs" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/nodejs?hl=en?hl=en

Reply via email to