Subject: [dhcwg] question about basic broadcast

From: Ranganath Sudarshan <[email-masked]>
Date: Thu, 27 Sep 2001 15:29:39 -0700 (PDT)

Hi,
I was trying to get the following scenario to work:

On one machine on the LAN, you have a Java program listening on some port
X for datagram packets coming in.

On another box, which is running FreeBSD and which does NOT have an IP
address configured (pre-DHCP configuration), I want to have code which
broadcasts a message to 255.255.255.255, port X, and I want the other box
running Java to pick up this datagram packet.

int on = 1;
char *msg = strdup("message");
sockfd = socket(AF_INET, SOCK_DGRAM, 0);
setsockopt(sockfd, SOL_SOCKET, SO_BROADCAST, &on, sizeof(on));
their_addr.sin_family = AF_INET;
their_addr.sin_port = htons(MYPORT);
their_addr.sin_addr.s_addr = inet_addr("255.255.255.255");
memset(&(their_addr.sin_zero), '\0', 8);
numbytes = sendto(sockfd, msg, strlen(msg), MSG_DONTROUTE);

numbytes is returned as -1 and the error: Network is Unreachable is
returned.

Does anyone know what the problem may be?  My basic aim is to have the
FreeBSD box without IP configured be able to communicate with my box
running a Java Datagram listener.  I would greatly appreciate any help on
this matter.  I realize that the problem is a subset of what DHCP enables
one to do, but I wish to only have this simple functionality, and not all
of the DHCP protocol.

Thanks,
RTS

_______________________________________________
dhcwg mailing list
[email-masked]
http://www1.ietf.org/mailman/listinfo/dhcwg

---

From: [email-masked]
Date: Fri, 28 Sep 2001 12:14:55 +0200 (CEST)

Hi Ranganath,

this list is for protocol developement issues, not for programing questions. 
Please try another available lists.

By the way: The below C program will never compile, and if you use the right 
parameter in sendto() you'll have more success.
Here is the definition of sendto:

ssize_t sendto(int s, const void *msg, size_t len, int flags, const struct 
sockaddr *to, socklen_t tolen)

See:
http://www.freebsd.org/cgi/man.cgi?
query=sendto&apropos=0&sektion=0&manpath=FreeBSD+4.3-RELEASE&format=html