Date: 23 Oct 95 20:37:35 EDT From: Ting.Cai@Dartmouth.EDU (Ting Cai) To: freebsd-hackers@freebsd.org Subject: Network Status Problem Message-ID: <9872290@vixen.Dartmouth.EDU>
next in thread | raw e-mail | index | archive | help
Hi! All: I am trying to find out an easy and quick way to tell if the network is up or down.I found that ioctl could retrieve the 'ifflags' which contains the infomation on if the network is up, but after hours of trying, ioctl still returns error: ioctl: Device not configured Here is the little program I wrote: struct ifreq data; struct sockaddr_in address; size = sizeof(struct sockaddr_in); if ((id = socket(PF_INET, SOCK_STREAM, 0)) < 0) { perror("socket"); exit(1); } bzero ((char *) &address, sizeof(address)); address.sin_family = PF_INET; address.sin_port = htons(SERV_TCP_PORT); address.sin_addr.s_addr = htonl (INADDR_ANY); if (bind(id,(struct sockaddr *) &address, size)) { perror("bind"); exit(1); } if ( ioctl(id,SIOCGIFFLAGS,&data ) < 0) { perror("ioctl"); exit(1); } /************* end of program ************************************/ Do you have some suggestions? or any other way to get the network status information? Many thanks to you all. Ting Cai at Dartmouth College email: tcai@cs.dartmouth.edu --UAA25927.814494928/dartvax.dartmouth.edu--
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?9872290>