broadcast
Web Server forum
Back To The Forum Home!Search!Private Messaging System

Web Server Talk Web Server Talk > Unix and Linux reviews > Free Unix support > Unix Programming > broadcast




  Last Thread   Next Thread Next
  Show Printable Version Email this Page Subscribe to this Thread      Post New Thread    Post A Reply      

    broadcast  
manish


View Ip Address Report This Message To A Moderator Edit/Delete Message


 
01-20-06 07: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...






[ Post a follow-up to this message ]



    Re: broadcast  
Gordon Burditt


View Ip Address Report This Message To A Moderator Edit/Delete Message


 
01-20-06 07: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





[ Post a follow-up to this message ]



    Re: broadcast  
manish


View Ip Address Report This Message To A Moderator Edit/Delete Message


 
01-20-06 07:50 AM

what if i write

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

how could i display the broadcast address on the stdout.






[ Post a follow-up to this message ]



    Re: broadcast  
David Schwartz


View Ip Address Report This Message To A Moderator Edit/Delete Message


 
01-20-06 07: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







[ Post a follow-up to this message ]



    Re: broadcast  
Pascal Bourguignon


View Ip Address Report This Message To A Moderator Edit/Delete Message


 
01-20-06 07: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"





[ Post a follow-up to this message ]



    Re: broadcast  
Thomas Maier-Komor


View Ip Address Report This Message To A Moderator Edit/Delete Message


 
01-23-06 11: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





[ Post a follow-up to this message ]



    Sponsored Links  




 





   All times are GMT. The time now is 11:22 AM.      Post New Thread    Post A Reply      
  Last Thread   Next Thread Next


Most Popular forums 

Forum Jump:
Rate This Thread:

Forum Rules:
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
HTML code is OFF
vB code is ON
Smilies are ON
[IMG] code is OFF
 
Medical and Health forum | Computer Games Reviews | Graphics design forum

Back To The Top
Home | Usercp | Faq | Register