Two bind() calls

46 views
Skip to first unread message

Emerson Espínola

unread,
Apr 2, 2012, 5:35:35 PM4/2/12
to nod...@googlegroups.com
Hi,

I'm trying to listen for datagrams in 2 address.

var dgram = require('dgram');
var server = dgram.createSocket("udp4");
server.bind(8001, "192.168.65.66");
server.bind(8001, "192.168.33.34");

I'm always able to bind to the first address, but with the second I always get error:
node.js:201
        throw e; // process.nextTick error, or 'error' event on first tick
              ^
Error: bind Unknown system errno 10038
    at errnoException (dgram.js:352:11)
    at dgram.js:123:15
    at lookup (dgram.js:49:12)
    at UDP.lookup4 [as lookup] (dgram.js:59:10)
    at Socket.bind (dgram.js:120:16)
...

What am I doing wrong?

[]'s
Emerson de Lira Espínola
 


Naouak

unread,
Apr 2, 2012, 5:38:51 PM4/2/12
to nod...@googlegroups.com
Have you tried listening on 2 different port. I don't think you can bind twice on the same port.

Naouak, Grade 2 de Kobal.
Site web: http://www.naouak.net





--
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 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?hl=en

Ben Noordhuis

unread,
Apr 2, 2012, 5:43:51 PM4/2/12
to nod...@googlegroups.com
On Mon, Apr 2, 2012 at 23:35, Emerson Espínola
<emerson...@gmail.com> wrote:
> Hi,
>
> I'm trying to listen for datagrams in 2 address.
>
> var dgram = require('dgram');
> var server = dgram.createSocket("udp4");
> server.bind(8001, "192.168.65.66");
> server.bind(8001, "192.168.33.34");
>
> I'm always able to bind to the first address, but with the second I always get error:
> node.js:201
>         throw e; // process.nextTick error, or 'error' event on first tick
>               ^
> Error: bind Unknown system errno 10038
>     at errnoException (dgram.js:352:11)
>     at dgram.js:123:15
>     at lookup (dgram.js:49:12)
>     at UDP.lookup4 [as lookup] (dgram.js:59:10)
>     at Socket.bind (dgram.js:120:16)
> ...
>
> What am I doing wrong?

You need to create two socket objects, one for each address you want
to bind to. It's kind of odd that Windows reports it as 10038
(WSAENOTSOCK).

Emerson Espínola

unread,
Apr 5, 2012, 6:46:53 AM4/5/12
to nod...@googlegroups.com
Thanks. It worked when I created two sockets objetcs.


[]'s
Emerson de Lira Espínola
 




2012/4/2 Ben Noordhuis <in...@bnoordhuis.nl>

Bert Belder

unread,
Apr 5, 2012, 11:30:05 AM4/5/12
to nodejs

On Apr 2, 11:43 pm, Ben Noordhuis <i...@bnoordhuis.nl> wrote:
> You need to create two socket objects, one for each address you want
> to bind to. It's kind of odd that Windows reports it as 10038
> (WSAENOTSOCK).

That was a libuv-win bug. It has been fixed in libuv:
https://github.com/joyent/node/commit/56a81011927940f03899a770c6ae4b50ce958cf9.

- Bert
Reply all
Reply to author
Forward
0 new messages