line-oriented protocols and future plans

49 views
Skip to first unread message

Abe Fettig

unread,
Aug 17, 2009, 11:35:56 PM8/17/09
to nod...@googlegroups.com
Hello,

I just came across Node last week, and as a fan of both the Twisted framework and the Javascript language I have to say I'm really digging what you're doing here. Nice work!

As a test project I'm implementing a little telnet server / javascript shell. In working on it so far I noticed a couple things:

1 - I had to roll my own implementation of buffering input until an end of line is received
2 - since File and Socket have different APIs I'd have to write separate wrappers if I wanted my JS shell to work both with stdin/stdout and over telnet.

So basically I'm wondering what your plans are for something like Twisted's LineReceiver, which is a standard class that handles the basics of line-oriented protocols, and can be subclassed for specific protocol implementations. Twisted also allows you to use the same protocol implementation with different "transports", like TCP or stdin/out, which is nice.

Is the plan to fill out Node with these kinds of utility classes, or are you keeping it lean and mean? And if you are planning to do these kinds of things, are you interested in contributions? :)

-Abe

Urban Hafner

unread,
Aug 18, 2009, 4:34:03 AM8/18/09
to nod...@googlegroups.com
Abe Fettig wrote:

> 1 - I had to roll my own implementation of buffering input until an end
> of line is received
> 2 - since File and Socket have different APIs I'd have to write separate
> wrappers if I wanted my JS shell to work both with stdin/stdout and over
> telnet.

IIRC, stdin/stdout is somewhat broken at the moment and is being
reworked at the moment.

> Is the plan to fill out Node with these kinds of utility classes, or are
> you keeping it lean and mean? And if you are planning to do these kinds
> of things, are you interested in contributions? :)

I think the plan is to keep Node lean. Currently there's no real module
system to load libraries (especially those written in C++) so it's all
part of node for now. Eventually these things might go into a standard
library. If this will be part of node itself or a separate project I
cannot say.

Urban

r...@tinyclouds.org

unread,
Aug 18, 2009, 4:42:25 AM8/18/09
to nod...@googlegroups.com
> As a test project I'm implementing a little telnet server / javascript
> shell. In working on it so far I noticed a couple things:
>
> 1 - I had to roll my own implementation of buffering input until an end of
> line is received

The stdin/stdout/stderr implementation is changing at the moment. Soon
it will emit events for line-buffered stdin data.

> 2 - since File and Socket have different APIs I'd have to write separate
> wrappers if I wanted my JS shell to work both with stdin/stdout and over
> telnet.

I hadn't considered doing this, but I will now. I'll get back to you.

> So basically I'm wondering what your plans are for something like Twisted's
> LineReceiver, which is a standard class that handles the basics of
> line-oriented protocols, and can be subclassed for specific protocol
> implementations. Twisted also allows you to use the same protocol
> implementation with different "transports", like TCP or stdin/out, which is
> nice.
>
> Is the plan to fill out Node with these kinds of utility classes, or are you
> keeping it lean and mean?

I lean towards no unless it's also necessary for internal usage -
which a LiveReceiver would not be.

> Are you interested in contributions? :)

Yes!

Abe Fettig

unread,
Aug 18, 2009, 11:48:24 AM8/18/09
to nod...@googlegroups.com
Thanks, Urban and Ry, for the info.


On Tue, Aug 18, 2009 at 4:42 AM, <r...@tinyclouds.org> wrote:


> Are you interested in contributions? :)

Yes!

I'm not set up on github yet (working on it), so apologies for not sending a real diff, but I found the bug breaking stdin at the moment. In file.js line 55:

self.fd = options.fd || null;

In the case of stdin options.fd is 0, which is considered false, therefore fd gets set to null intead of 0. I think what you really want there is:

self.fd = typeof options.fd != 'undefined' ? options.fd : null;

I made this change locally, and now I'm able to read from stdin just fine.

-Abe

ry

unread,
Aug 19, 2009, 6:57:17 AM8/19/09
to nodejs
Thanks, applied in 53b3d6be351907d2461f6a17d41932f24a7d8a61
Reply all
Reply to author
Forward
0 new messages