From owner-freebsd-questions Mon Oct 23 17:35:12 1995 Return-Path: owner-questions Received: (from root@localhost) by freefall.freebsd.org (8.6.12/8.6.6) id RAA11965 for questions-outgoing; Mon, 23 Oct 1995 17:35:12 -0700 Received: from dartvax.dartmouth.edu (dartvax.dartmouth.edu [129.170.16.4]) by freefall.freebsd.org (8.6.12/8.6.6) with ESMTP id RAA11958 for ; Mon, 23 Oct 1995 17:35:09 -0700 Received: from vixen.Dartmouth.EDU (vixen.dartmouth.edu [129.170.208.15]) by dartvax.dartmouth.edu (8.6.12-DND/8.6.12) with SMTP id UAA17693 for ; Mon, 23 Oct 1995 20:35:07 -0400 Message-id: <9871831@vixen.Dartmouth.EDU> Date: 23 Oct 95 20:27:15 EDT From: Ting.Cai@Dartmouth.EDU (Ting Cai) Subject: Help on network status To: freebsd-questions@freebsd.org Sender: owner-questions@freebsd.org Precedence: bulk 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