|
Home > Archive > Unix Programming > June 2005 > PF_INET vs. AF_INET
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 |
PF_INET vs. AF_INET
|
|
| Roman Mashak 2005-06-22, 7:54 am |
| Hello, All!
I supposed that PF_* and AF_* declarations are identical, at least according
to bits/socket.h. So why I can't use this piece of code:
struct sockaddr_in s_in;
int sd; /* socket descriptor */
struct ifreq ifr;
if ( sd = socket(PF_INET, SOCK_RAW, 0) < 0 ) {
perror("socket() error!");
exit(1);
}
bzero(&s_in, sizeof(s_in));
s_in.sin_family = AF_INET;
if ( bind(sd, (struct sockaddr *)&s_in, sizeof(s_in)) < 0) {
perror("bind() error!");
exit(1);
}
.....
close(sd);
I receive error: storage size of `ifr' isn't known.
gcc -ansi -o skt skt.c
Without '-ansi' flag everything is fine. What is the point?
With best regards, Roman Mashak. E-mail: mrv@tusur.ru
| |
| Rainer Temme 2005-06-22, 7:54 am |
| Hi Roman,
since your example doesn't shows just a snippet of code
rather than something that really compiles my
assumption is the following:
Your problem is not realated to AF_INET or PF_INET ...
Your problem is that your not including the correct headerfile
that defines the ifreq-struct.
May be in non-ansi mode this is ignored because you
never make use of the variable ifr.
As well quite likely in ansi-mode the compiler complains
about this.
Regards ... Rainer
| |
| Villy Kruse 2005-06-22, 5:57 pm |
| On Wed, 22 Jun 2005 22:05:08 +0900,
Roman Mashak <mrv@tusur.ru> wrote:
>
> I receive error: storage size of `ifr' isn't known.
> gcc -ansi -o skt skt.c
>
> Without '-ansi' flag everything is fine. What is the point?
>
You only use -ansi if you don't use any extension such as sockets
or other POSIX defined functions.
Villy
|
|
|
|
|