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 6587735
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T16:57:21+00:00 2026-05-25T16:57:21+00:00

Im creating an UDP socket (centos 6), which i want to send broadcast message.

  • 0

Im creating an UDP socket (centos 6), which i want to send broadcast message. Everything works, creating socket works – socket(..) returns value=25, but:

int val = 1;
      if (setsockopt(a, SOL_SOCKET, SO_BROADCAST, &val, sizeof(val)) < 1){
          debug("setsockoopt failed with errno: %d, socket %d", errno, a);
      }

setsockopt sets errno to value = 2. Communictaion works, im sending udp packet to x.x.x.255 host, and all my apps recives it, but im wondering from where that errno came (errno=2=no such file or directory)

best regards

  • 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-25T16:57:22+00:00Added an answer on May 25, 2026 at 4:57 pm

    Upon successful completion, the value 0 is returned; otherwise the
    value -1 is returned and the global variable errno is set to indicate the
    error.

    That’s from the setsockopt manpage returns 0 on success, so it’s just your condition that’s wrong. If there was no error, errno’s value is not relevant, and that’s why here you get a rather absurd value.

    if (setsockopt(a, SOL_SOCKET, SO_BROADCAST, &val, sizeof(val)) != 0){
    

    is what you need.

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

Sidebar

Related Questions

I am creating a UDP socket ( AF_INET , SOCK_DGRAM , IPPROTO_UDP ) via
I am creating a dhcp client in Linux(Ubuntu). I am creating a udp socket
I am creating a Chrome extension which will send the URL of every page
I am creating a UDP socket client in C (unicast) and is wondering why
I want to send OSC messages from iphone to another programme (max/msp) by creating
I'm creating 2 programs which one of them sends UDP packets from an Adnroid
I have a Client-Server Perl program. I want to send a message stored in
I'm creating a thread that runs a UDP Client that receives a message, after
Creating a server-side socket will fail if I'm trying to use the same port
I'm creating an UDP SocketServer, and I would like to shutdown if I'm receiving

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.