I don't know if anyone else can verify this, but the bug listed below
seems to be BSD socket related (ie OS related) 

I hacked some code together from an online example and included what
Java does on the server side , compile cc -o serv serv.c and
test with the Broadcaster client from the bug report.

If the ip address field is not used then the server gets the broadcast
packets
(it works) If the address is used then it doesn't. I'm thinking that
this
may be trapped elsewhere and not in Java 

regards
calvin



Jason Gilbert wrote:
> 

> 3) Bug 4191980
> (http://developer.java.sun.com/developer/bugParade/bugs/4191980.html).
>    It's amazing that this has been around since 1.1.6 (probably
> earlier).  Sadly, if
>    the jdk was in fact Free Software this would have easily been
> fixed.  Don't mention
>    the Sun open source license (I don't remember what it's called
> today).  That's more
>    of a lock-in than Microsoft.  At least they just lock you into
> using there software
>    by not being compatible with other software.  Sun wants people
> to effectively lock
>    themselves into using only the Sun implementation.  There
> attempt at blocking
>    'forking' basically would appear to block creating or working
> on another implementation.
>    Kaffe for instance.  Or blocking real innovation by allowing
> someone to say, "hey,
>    these people are completely off base with their impl, I could
> make the JVM 100x faster
>    by doing X"  and then release it under the GPL.  they're
> already tainted.  I think the
>    shortcoming is basically that Sun is trying to create this
> "community" which seems to
>    be on only a product by product basis when the real community
> already exists which is
>    the software developer community. small pond, largest pond.
> 

> jason
> 
> --
> Jason Gilbert | http://home.hiwaay.net/~gilbertj/
> ------------------------------------------------------
> I wish I could make the garbage collector thread in my
> brain less aggressive.
> 
> ----------------------------------------------------------------------
> To UNSUBSCRIBE, email to [EMAIL PROTECTED]
> with a subject of "unsubscribe". Trouble? Contact [EMAIL PROTECTED]
#include <stdio.h>
 #include <string.h>
 #include <errno.h>
 #include <sys/socket.h>
  
 #include <netinet/in.h>
 #include <arpa/inet.h>
  
 typedef int                    SIZE_T;
 #define PACKET_SIZE            1024
  
  
 main(int argc, char **argv)
 {
         int            rr;
         int            rc;
         int            sockfd;
         SIZE_T          client_addr_len;
         char            *cmd_name;
         char            send_data[PACKET_SIZE];
         char            recv_data[PACKET_SIZE];
         struct sockaddr_in      servaddr;
         struct sockaddr client_addr;
  
         cmd_name = argv[0];
  
         /*
         * Create a socket.
         */
         sockfd = socket(AF_INET, SOCK_DGRAM, 0);
         if (sockfd < 0) {
                 printf("%s: socket errno = %d\n", cmd_name, errno);                 
exit(-1);
         }
  
         /*
         * Initialize the address the socket will bind to.
         */
         bzero(&servaddr, sizeof(servaddr));
         servaddr.sin_family      = AF_INET;
         servaddr.sin_port        = htons(3000);
         /*
         * NOTE: assigning INADDR_ANY works
  but listening to the machines own address does not receive broadcast
udp for that subnet */
         servaddr.sin_addr.s_addr = htonl(INADDR_ANY);
         /*servaddr.sin_addr.s_addr = htonl(0x81907D7C);*/
         /*servaddr.sin_addr.s_addr = htonl(0x81907D6F);*/
  
         /*
         * Bind the socket to the address.
         */
         rc = bind(sockfd, (struct sockaddr *) &servaddr,
                   sizeof(servaddr));
         if (rc < 0) {
                 printf("%s: bind errno = %d\n", cmd_name, errno);                 
exit(-1);
         }
  
         /*
         * In each loop iteration, we wait for a packet from the         * client.  
When a packet arrives, we echo its contents
         * and send a response back to the client of the form
         * "response #rr".
         */
         for (rr = 1; ; rr++) {
                 client_addr_len = sizeof(client_addr);
                 printf("%s: about to receive packet\n", cmd_name);                 
fflush(stdout);
                 /*
                 * Wait for a packet from the client.
                 */
                 rc = recvfrom(sockfd, recv_data, PACKET_SIZE, 0,                      
         &client_addr, &client_addr_len);                 if (rc
 < 0) {
                         printf("%s: recvfrom failed: errno = %d\n",                   
              cmd_name, errno);
                 } else {
                         printf("%s: recvfrom received packet #%d: %s\n",              
                   cmd_name, rr, recv_data);
                 }
         }
 }

Reply via email to