From owner-freebsd-hackers Fri Aug 3 11: 7:25 2001 Delivered-To: freebsd-hackers@freebsd.org Received: from elvis.mu.org (elvis.mu.org [216.33.66.196]) by hub.freebsd.org (Postfix) with ESMTP id 3447A37B412 for ; Fri, 3 Aug 2001 11:07:22 -0700 (PDT) (envelope-from bright@elvis.mu.org) Received: by elvis.mu.org (Postfix, from userid 1192) id 226AB81D0C; Fri, 3 Aug 2001 13:07:22 -0500 (CDT) Date: Fri, 3 Aug 2001 13:07:22 -0500 From: Alfred Perlstein To: Ullasan Kottummal Cc: freebsd-hackers@freebsd.org Subject: Re: Select call gives EBADF Message-ID: <20010803130722.D85642@elvis.mu.org> References: Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline User-Agent: Mutt/1.2.5i In-Reply-To: ; from ullasan.kottummal@uk.zurich.com on Fri, Aug 03, 2001 at 12:21:42PM +0100 Sender: owner-freebsd-hackers@FreeBSD.ORG Precedence: bulk List-ID: List-Archive: (Web Archive) List-Help: (List Instructions) List-Subscribe: List-Unsubscribe: X-Loop: FreeBSD.ORG * Ullasan Kottummal [010803 06:23] wrote: > Hi, > I am using select() call under HP-UX 10.20 for timing on socket. It throws > the error EBADF. I don't understand why it happens. This isn't an HPUX support forum. Your problem is that: 1) you're using HPUX 2) you didn't read the select(2) manpage carefully enough 3) you didn't provide enough context for this code to be useful Here's what's probably wrong though: > The socket is opened successfully before calling the select and the > descriptor is valid. > > I will give the relevant code below. > > int mask; > struct fd_set readmask ; > readmask.fds_bits[0] = 0; > struct fd_set readfds; > int nfound, i; > struct timeval timeout; > > mask = MASK(m_iSocket); > readmask.fds_bits[0] |= mask; > readfds.fds_bits[0] = readmask.fds_bits[0]; > > timeout.tv_sec = m_iSelectTimeout; > timeout.tv_usec = 0; > FD_ZERO(&readfds); Shouldn't this be: FD_ZERO(&readfds); FD_SET(m_iSocket, &readfds); I mean how else is select supposed to know which file you're interested in??? > > if ((nfound = select (SOCKETS, &readfds, 0, 0, &timeout)) == -1) > { > cerr << "==>Select call failed : " << endl; > //Errror checking done > ....... > ........ > } -- -Alfred Perlstein [alfred@freebsd.org] Ok, who wrote this damn function called '??'? And why do my programs keep crashing in it? To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-hackers" in the body of the message