Unix Programming - broadcast

This is Interesting: Free IT Magazines  
Home > Archive > Unix Programming > January 2006 > broadcast





You are viewing an archived Text-only version of the thread. To view this thread in it's original format and/or if you want to reply to this thread please [click here]

Author broadcast
manish

2006-01-20, 2:50 am

i wrote this piece of code

#include<sys/ioctl.h>
#include <stropts.h>
#include <unistd.h>

int
main()
{

printf(" %d",ioctl(0,SIOCGIFBRDADDR, 0));
}

this is not providing me with any output..i m working on solaris 2
platform...

Gordon Burditt

2006-01-20, 2:50 am

>i wrote this piece of code
>
>#include<sys/ioctl.h>
>#include <stropts.h>
>#include <unistd.h>
>
>int
>main()
>{
>
> printf(" %d",ioctl(0,SIOCGIFBRDADDR, 0));
>}
>
>this is not providing me with any output..i m working on solaris 2
>platform...


You have stdin redirected from an inet socket?

Gordon L. Burditt
manish

2006-01-20, 2:50 am

what if i write

printf(" %d", ioctl(1,SIOCGIFBRDADDR,0));

how could i display the broadcast address on the stdout.

David Schwartz

2006-01-20, 2:50 am


"manish" <manishmodgil@gmail.com> wrote in message
news:1137738813.429028.39760@o13g2000cwo.googlegroups.com...

> what if i write
>
> printf(" %d", ioctl(1,SIOCGIFBRDADDR,0));
>
> how could i display the broadcast address on the stdout.


The broadcast address *of what*?

DS


Pascal Bourguignon

2006-01-20, 2:50 am

"manish" <manishmodgil@gmail.com> writes:

> what if i write
>
> printf(" %d", ioctl(1,SIOCGIFBRDADDR,0));
>
> how could i display the broadcast address on the stdout.


You have stdout redirected to an inet socket?

Anyways, read man ioctl
and understand what it returns (hint: check the RETURN VALUE section).

Then read man ioctl_list (or the equivalent on your OS, I'm a little
Linux-centric) and understand what the SIOCGIFBRDADDR row means:

For each ioctl, I list its numerical value, its name, and its
argument type.

An argument type of 'const struct foo *' means the argument is
input to the kernel. 'struct foo *' means the kernel outputs the
argument. If the kernel uses the argument for both input and
output, this is marked with // I-O.

...
0x00008919 SIOCGIFBRDADDR struct ifreq * // I-O
...


Something like:

struct ifreq request;
int res=ioctl(socket,SIOCGIFBRDADDR,&request);
if(res<0){ perror("ioctl SIOCGIFBRDADDR"); exit(1); }
do_something_with(request);

--
__Pascal Bourguignon__ http://www.informatimago.com/

"You cannot really appreciate Dilbert unless you read it in the
original Klingon"
Thomas Maier-Komor

2006-01-23, 6:13 pm

manish wrote:
> i wrote this piece of code
>
> #include<sys/ioctl.h>
> #include <stropts.h>
> #include <unistd.h>
>
> int
> main()
> {
>
> printf(" %d",ioctl(0,SIOCGIFBRDADDR, 0));
> }
>
> this is not providing me with any output..i m working on solaris 2
> platform...
>


I don't know what you want to achieve, but you don't get any output,
because your printf is missing a terminating \n. So line buffering might
be the reason that you won't see the result (-1) of your erroneous ioctl.

Tom
Sponsored Links






Free braindumps | Software forum | Database administration forum

Copyright 2003 - 2008 webservertalk.com