Account Options

  1. Sign in
The old Google Groups will be going away soon, but your browser is incompatible with the new version.
Google Groups Home
« Groups Home
Message from discussion net.createServer
The group you are posting to is a Usenet group. Messages posted to this group will make your email address visible to anyone on the Internet.
Your reply message has not been sent.
Your post was successful
 
From:
To:
Cc:
Followup To:
Add Cc | Add Followup-to | Edit Subject
Subject:
Validation:
For verification purposes please type the characters you see in the picture below or the numbers you hear by clicking the accessibility icon. Listen and type the numbers you hear
 
Mark Volkmann  
View profile  
 More options Sep 7 2012, 10:21 am
From: Mark Volkmann <r.mark.volkm...@gmail.com>
Date: Fri, 7 Sep 2012 09:21:30 -0500
Local: Fri, Sep 7 2012 10:21 am
Subject: Re: [nodejs] net.createServer

On Fri, Sep 7, 2012 at 9:09 AM, Ben Noordhuis <i...@bnoordhuis.nl> wrote:

The client queues write requests until the connection handshake is

> done. Said handshake is complete when the server accepts the
> connection, which node does right before it calls your connListener
> function.

If that is true then why is the first message from the client lost if I do
this?
Note that on my machine (OSX) the message is lost if the timeout is 2 ms or
more, but not if it is less than 2.
Maybe the client queues write requests until the connListener function
completes.

server.js

var net = require('net');
function dataListener(data) {
  console.log('received', data.toString());

}

function connListener(socket) {
  setTimeout(function () {
    socket.on('data', dataListener);
  }, 2);
}

var server = net.createServer(connListener);
server.listen(8019);

client.js

var net = require('net');
var socket = net.connect(8019);
socket.write('Is this lost?');

--
R. Mark Volkmann
Object Computing, Inc.


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.