Bugzilla will be upgraded to version 5.0 on December 2, 2018. The outage period for the upgrade will start at 0:00 UTC and have a duration of 12 hours
Bug 10101 - INADDR_BROADCAST does not work for broadcast messages
INADDR_BROADCAST does not work for broadcast messages
Product: Red Hat Linux
Classification: Retired
Component: kernel (Show other bugs)
All Linux
medium Severity medium
: ---
: ---
Assigned To: Michael K. Johnson
Depends On:
  Show dependency treegraph
Reported: 2000-03-09 20:53 EST by Ron Weigel
Modified: 2008-05-01 11:37 EDT (History)
0 users

See Also:
Fixed In Version:
Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of:
Last Closed: 2000-05-22 11:40:36 EDT
Type: ---
Regression: ---
Mount Type: ---
Documentation: ---
Verified Versions:
Category: ---
oVirt Team: ---
RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: ---

Attachments (Terms of Use)

  None (edit)
Description Ron Weigel 2000-03-09 20:53:47 EST
The following code gives ENETUNREACH on RedHat 6.1 but works on other
versions of Linux:

#include <unistd.h>
#include <errno.h>
#include <string.h>
#include <sys/socket.h>
#include <netinet/in.h>
#define SOCKET_ERROR -1
#define closesocket close
typedef int SOCKET;
typedef struct sockaddr SOCKADDR;
typedef struct sockaddr_in SOCKADDR_IN;
#define FALSE 0
#define TRUE 1

int sendbroadcast(int sendport, const char* sendbuf, int sendbytes)

  if ((s = socket(PF_INET, SOCK_DGRAM, 0)) == SOCKET_ERROR)
    return errno;

  int err = 0;

  int optval = TRUE;
  if (setsockopt(s, SOL_SOCKET, SO_BROADCAST, reinterpret_cast<const char*>
(&optval), sizeof(optval)) == SOCKET_ERROR)
    err = errno;
    SOCKADDR_IN sockAddr;
    memset(&sockAddr, 0, sizeof(sockAddr));

    sockAddr.sin_family = AF_INET;
    sockAddr.sin_addr.s_addr = htonl(INADDR_BROADCAST);
    sockAddr.sin_port = htons(sendport);

    int flags = 0;
    int bytes = sendto(s, sendbuf, sendbytes, flags,
reinterpret_cast<SOCKADDR*>(&sockAddr), sizeof(sockAddr));

    if (bytes == SOCKET_ERROR)
      err = errno;

  return err;
Comment 1 Jeff Johnson 2000-05-14 17:06:59 EDT
This smells like a kernel problem, so I'm changing the component.
What kernel are you using?
Comment 2 Cristian Gafton 2000-05-22 11:40:59 EDT
assigned to dledford
Comment 3 Alan Cox 2000-08-08 16:10:02 EDT
This depends solely on routing setup

Note You need to log in before you can comment on or make changes to this bug.