4 #include <sys/socket.h>
7 #include <netinet/in.h>
10 * open a socket, get the process group information of the socket, and use the
11 * socket to get the network interface configuration list
13 main(int argc
, char *argv
[])
19 sock
= socket(AF_INET
, SOCK_DGRAM
, IPPROTO_UDP
);
22 perror("Cannot create socket");
26 /* use ioctl() to get the process group information */
28 int get_process_group
;
30 ioctl_result
= ioctl(sock
, SIOCGPGRP
, (char *) &get_process_group
);
36 fprintf(stderr
, "errno %d ", my_errno
);
37 perror("ioctl(get process group)");
41 /* use ioctl() to get the interface configuration list */
43 static struct ifconf ifc
; /* init to 0 */
45 ioctl_result
= ioctl(sock
, SIOCGIFCONF
, (char *) &ifc
);
51 fprintf(stderr
, "errno %d ", my_errno
);
52 perror("ioctl(get interface configuration list)");