[PATCH] UDP / dgram module

288 views
Skip to first unread message

Paul Querna

unread,
Jun 12, 2010, 3:19:48 AM6/12/10
to nod...@googlegroups.com
Hello,

I have a working UDP implementation for node up on github:
<http://github.com/pquerna/node/tree/udp>

Just the patch:
<http://hera.kimaker.com/~chip/patches/node_dgram_v1.patch>

'Features':
- Adds new dgram module, for all data-gram type transports
- Supports both UDP client and servers
- Supports Unix Daemon sockets in DGRAM mode too (think syslog)
- Uses a shared Buffer and slices that as needed to be reasonably performant.
- One supplied test program so far, test-dgram-pingpong
- Passes test cases on osx 10.6 and ubuntu 9.10

Examples:
<http://gist.github.com/435513>
<http://github.com/pquerna/node/blob/udp/test/simple/test-dgram-pingpong.js>

Thanks to Ryan for giving feedback on a first version earlier today.

Thoughts?

Thanks,

Paul

r...@tinyclouds.org

unread,
Jun 12, 2010, 5:43:02 AM6/12/10
to nod...@googlegroups.com
On Sat, Jun 12, 2010 at 12:19 AM, Paul Querna <pqu...@apache.org> wrote:
> Hello,
>
> I have a working UDP implementation for node up on github:
>  <http://github.com/pquerna/node/tree/udp>


Thanks Paul, this is great! Landed in 02da5ed.

r...@tinyclouds.org

unread,
Jun 12, 2010, 5:49:18 AM6/12/10
to nod...@googlegroups.com
A documentation patch would be welcome!

Matt Ranney

unread,
Jun 12, 2010, 9:17:03 AM6/12/10
to nod...@googlegroups.com
Nice! That was fast.

What will you do for the weekend though?

Elijah Insua

unread,
Jun 12, 2010, 2:39:39 PM6/12/10
to nod...@googlegroups.com
Very nice! thank you Paul!

-- Elijah

On Sat, Jun 12, 2010 at 9:17 AM, Matt Ranney <m...@ranney.com> wrote:
Nice!  That was fast.

What will you do for the weekend though?

--
You received this message because you are subscribed to the Google Groups "nodejs" group.
To post to this group, send email to nod...@googlegroups.com.
To unsubscribe from this group, send email to nodejs+un...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/nodejs?hl=en.


Brian Hammond

unread,
Jun 12, 2010, 11:03:46 PM6/12/10
to nodejs
This is a wonderful development. Thank you!

On Jun 12, 3:19 am, Paul Querna <pque...@apache.org> wrote:
> Hello,
>
> I have a working UDP implementation for node up on github:
>   <http://github.com/pquerna/node/tree/udp>
>
> Just the patch:
>  <http://hera.kimaker.com/~chip/patches/node_dgram_v1.patch>
>
> 'Features':
>   - Adds new dgram module, for all data-gram type transports
>   - Supports both UDP client and servers
>   - Supports Unix Daemon sockets in DGRAM mode too (think syslog)
>   - Uses a shared Buffer and slices that as needed to be reasonably performant.
>   - One supplied test program so far, test-dgram-pingpong
>   - Passes test cases on osx 10.6 and ubuntu 9.10
>
> Examples:
>   <http://gist.github.com/435513>
>   <http://github.com/pquerna/node/blob/udp/test/simple/test-dgram-pingpo...>

Chris Dew

unread,
Jun 14, 2010, 1:17:13 AM6/14/10
to nodejs
Thanks, this looks very useful.

Slightly off-topic: Are there any functions in NodeJS, or in
Javascript generally, to process the bytes in a UDP packet (or any
buffer) as (C-style) longs, unsigned shorts, doubles, floats, or even
structs?

Regards,

Chris.

Brian Hammond

unread,
Jun 14, 2010, 1:21:17 AM6/14/10
to nodejs
Check out node-msgpack

Brian Hammond

unread,
Jun 14, 2010, 1:27:52 AM6/14/10
to nodejs
Hi -

I'm trying to use the UDP-enabled version of Node to send datagrams
over a UNIX socket.

I have a simple "echo" server. I might be missing something here but
the `send` seems to trigger the readability of the fd which causes the
"message" event to be emitted with the message I'm trying to echo back
through the domain socket.

Help?

For kicks, the client is in C.

http://gist.github.com/437301

Thanks,
Brian

On Jun 12, 3:19 am, Paul Querna <pque...@apache.org> wrote:
> Hello,
>
> I have a working UDP implementation for node up on github:
>   <http://github.com/pquerna/node/tree/udp>
>
> Just the patch:
>  <http://hera.kimaker.com/~chip/patches/node_dgram_v1.patch>
>
> 'Features':
>   - Adds new dgram module, for all data-gram type transports
>   - Supports both UDP client and servers
>   - Supports Unix Daemon sockets in DGRAM mode too (think syslog)
>   - Uses a shared Buffer and slices that as needed to be reasonably performant.
>   - One supplied test program so far, test-dgram-pingpong
>   - Passes test cases on osx 10.6 and ubuntu 9.10
>
> Examples:
>   <http://gist.github.com/435513>
>   <http://github.com/pquerna/node/blob/udp/test/simple/test-dgram-pingpo...>

r...@tinyclouds.org

unread,
Jun 14, 2010, 3:16:29 AM6/14/10
to nod...@googlegroups.com
On Sun, Jun 13, 2010 at 10:17 PM, Chris Dew <cms...@gmail.com> wrote:
> Thanks, this looks very useful.
>
> Slightly off-topic: Are there any functions in NodeJS, or in
> Javascript generally, to process the bytes in a UDP packet (or any
> buffer) as (C-style) longs, unsigned shorts, doubles, floats, or even
> structs?

No. I've been meaning to add 'pack' and 'unpack' functionality to
buffers for a while now. You can find a few examples in node-amqp:

http://github.com/ry/node-amqp/blob/5abe293f2206347153abc7206f55a3ef5b1338fb/amqp.js#L238

Chris Dew

unread,
Jun 14, 2010, 4:13:45 AM6/14/10
to nodejs
The examples are useful. Thanks for writing NodeJS.

I'm using NodeJS for a commercial project. I started using NodeJS for
a proof-of-concept, but no major problems were encountered. NodeJS is
functioning as the message switch, while Django is used for the more
'static' parts of the application (its ORM / admin gets simple things
working quickly).

All the best,

Chris.
> http://github.com/ry/node-amqp/blob/5abe293f2206347153abc7206f55a3ef5...

Chris Dew

unread,
Jun 14, 2010, 4:16:42 AM6/14/10
to nodejs
Thanks for the hint, but I'm looking for a little more control as I'm
dealing with existing formats/protocols.

Regards,

Chris.

Peter Griess

unread,
Jun 14, 2010, 10:34:55 AM6/14/10
to nod...@googlegroups.com
This is probably what you want.

http://github.com/pgriess/node-jspack

Peter

Chris Dew

unread,
Jul 7, 2010, 3:47:55 AM7/7/10
to nodejs
That's exactly what I'm looking for.

Thanks,

Chris.
Reply all
Reply to author
Forward
0 new messages