I agree that it doesn't work. I'm trying a slightly different
method, but I get a message saying permission is
denied when I try to broadcast to my subnet.
I'm guessing it's a Debian configuration thing, anybody know? Dave
did you figure it out?
G.
--- In Dave Cramer <> wrote:
>
> Any ideas why we can't send a udp broadcast message with the
> following code ?
>
> int main( int arc, char *argv[])
> {
> int flag=1;
> int sd;
> char testbuff[] = {"1234567890"};
> struct sockaddr_in bcast_addr;
>
> if ((sd =socket (AF_INET, SOCK_DGRAM, IPPROTO_UDP))==-1)
> {
> fprintf(stderr,"socket error\n");
> exit(-1);
> }
> if ( setsockopt(sd,SOL_SOCKET,SO_BROADCAST,(char *)
> &flag,sizeof(flag)) < 0 )
> {
> fprintf(stderr,"unable to set broadcast\n");
> exit(-1);
> }
> memset( &bcast_addr,0,sizeof( struct sockaddr_in) );
> bcast_addr.sin_family = AF_INET;
> bcast_addr.sin_addr.s_addr = 0xffffffff;
> bcast_addr.sin_port=5433;
> if ( sendto( sd,testbuff, sizeof( testbuff),0,
> ( const struct sockaddr * ) &bcast_addr,
> sizeof( const struct sockaddr_in ) ) == -1)
> {
> fprintf( stderr, "error sending\n");
> exit(-1);
> }
>
> fprintf( stderr,"everything ok\n");
>
>
> }
>
Yahoo! Groups Links
<*> To visit your group on the web, go to:
http://groups.yahoo.com/group/ts-7000/
<*> Your email settings:
Individual Email | Traditional
<*> To change settings online go to:
http://groups.yahoo.com/group/ts-7000/join
(Yahoo! ID required)
<*> To change settings via email:
<*> To unsubscribe from this group, send an email to:
<*> Your use of Yahoo! Groups is subject to:
http://docs.yahoo.com/info/terms/
|