One would assume that there is some other async code happening.  You have
to get your data from somewhere and that somewhere is usually async.


On Fri, Feb 1, 2013 at 3:50 AM, Ben Noordhuis <[email protected]> wrote:

> On Fri, Feb 1, 2013 at 9:42 AM, darcy <[email protected]> wrote:
> > Yes, I mean write+callback can be sync in some cases.
> > If the callback should be promised to be async, we can use
> > process.nextTick(cb.bind(this)) in Socket._write().
> > But I think in userland it's not important whether write callback is
> sync or
> > async. And in current implement callback is also sync if some error
> occurs.
>
> The callback should always be asynchronous (i.e. run on the next
> tick), or you introduce the risk of stack overflows.
>
> Consider this code:
>
>   var conn = net.connect(/* ... */, function() {
>     function write() { conn.write('PING', write) }
>     write();
>   });
>
> If the network connection is fast enough that the write always
> succeeds and the callback is synchronous, you'll overflow the call
> stack in seconds flat.
>
> --
> --
> 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
>
> ---
> You received this message because you are subscribed to the Google Groups
> "nodejs" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to [email protected].
> For more options, visit https://groups.google.com/groups/opt_out.
>
>
>

-- 
-- 
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

--- 
You received this message because you are subscribed to the Google Groups 
"nodejs" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
For more options, visit https://groups.google.com/groups/opt_out.


Reply via email to