Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7440227
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 29, 20262026-05-29T10:49:09+00:00 2026-05-29T10:49:09+00:00

I’m using Node.js 0.6.9, and am trying to send a datagram broadcast package. Code:

  • 0

I’m using Node.js 0.6.9, and am trying to send a datagram broadcast package. Code:

var sys = require('util');
var net = require('net');

var dgram = require('dgram');
var message = new Buffer('message');
var client = dgram.createSocket("udp4");
client.setBroadcast(true);
client.send(message, 0, message.length, 8282, "192.168.1.255", function(err, bytes) {
  client.close();
});

Running the code:

$ node test.js
node.js:201
        throw e; // process.nextTick error, or 'error' event on first tick
              ^
Error: setBroadcast EBADF
    at errnoException (dgram.js:352:11)
    at Socket.setBroadcast (dgram.js:227:11)
    at Object.<anonymous> (/home/letharion/tmp/collision/hello.js:25:8)
    at Module._compile (module.js:444:26)
    at Object..js (module.js:462:10)
    at Module.load (module.js:351:32)
    at Function._load (module.js:310:12)
    at Array.0 (module.js:482:10)
    at EventEmitter._tickCallback (node.js:192:41)

Some googling reveals that “EBADF” means “The socket argument is not a valid file descriptor”. But I don’t understand enough about the problem for that to be helpful.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-29T10:49:10+00:00Added an answer on May 29, 2026 at 10:49 am

    First of all, you seem to have trouble understanding the format of the stacktrace, so let’s clarify it before we go to the actual error that is thrown here.

    Format of a node.js Stacktrace

    node.js:201
            throw e; // process.nextTick error, or 'error' event on first tick
    

    This part is just the location where the internal NodeJS logic choked up and put out the error below:

    The actual error stacktrace follows, it shows the deepest location in the callstack first, so going down in the stack trace, brings you up in the call hierachy, eventually leading you to the point in your code where everything began.

    Error: setBroadcast EBADF
        at errnoException (dgram.js:352:11)
        at Socket.setBroadcast (dgram.js:227:11)
        at Object.<anonymous> (/home/letharion/tmp/collision/hello.js:25:8)
        at Module._compile (module.js:444:26)
        at Object..js (module.js:462:10)
        at Module.load (module.js:351:32)
        at Function._load (module.js:310:12)
        at Array.0 (module.js:482:10)
        at EventEmitter._tickCallback (node.js:192:41)
    

    First it fails in dgram.js on line 352, dgram.js is a internal node.js module abstracting the “low level” code. Line 352 is in a function containing generic logic for throwing errors.

    It was called at dgram.js in line 227, after a failed if check which wraps the call to the wrapped native UDP sockets setBroadcast method.

    Going up one more layer, we end up at your hello.js file on line 25 with the client.setBroadcast(true); call.

    The rest is more node.js code resulting from the initial load of the hello.js file.

    The actual Error

    The error thrown by the native code which node.js wraps here is EBADF looking this up in conjunction with UDP gives us:

    EBADF
        The socket argument is not a valid file descriptor. 
    

    By going further down into the node.js rabbit hole, we end up in the udp wrapper, which wraps the uv wrapper for the actual C implementation, in the uv wrapper we find:

    /*
    * Set broadcast on or off
    *
    * Arguments:
    * handle UDP handle. Should have been initialized with
    * `uv_udp_init`.
    * on 1 for on, 0 for off
    *
    * Returns:
    * 0 on success, -1 on error.
    */
    

    Leading us to the conclusion that your socket has not been initialized yet.

    In the end, binding the socket via client.bind(8000) fixed the missing initialization and made the program run.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm new to using the Perl treebuilder module for HTML parsing and can't figure
That's pretty much it. I'm using Nokogiri to scrape a web page what has
link Im having trouble converting the html entites into html characters, (&# 8217;) i
I am trying to understand how to use SyndicationItem to display feed which is
Basically, what I'm trying to create is a page of div tags, each has
I'm using v2.0 of ClassTextile.php, with the following call: $testimonial_text = $textile->TextileRestricted($_POST['testimonial']); ... and
We're building an app, our first using Rails 3, and we're having to build
I'm parsing an RSS feed that has an &#8217; in it. SimpleXML turns this
I have this code: - (void)parser:(NSXMLParser *)parser foundCDATA:(NSData *)CDATABlock { NSString *someString = [[NSString
We are using XSLT to translate a RIXML file to XML. Our RIXML contains

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.