Date: Fri, 3 Aug 2001 13:07:22 -0500 From: Alfred Perlstein <bright@mu.org> To: Ullasan Kottummal <ullasan.kottummal@uk.zurich.com> Cc: freebsd-hackers@freebsd.org Subject: Re: Select call gives EBADF Message-ID: <20010803130722.D85642@elvis.mu.org> In-Reply-To: <OF7573D16B.3BCF5B08-ON80256A9D.003E5851@zurich.com>; from ullasan.kottummal@uk.zurich.com on Fri, Aug 03, 2001 at 12:21:42PM %2B0100 References: <OF7573D16B.3BCF5B08-ON80256A9D.003E5851@zurich.com>
next in thread | previous in thread | raw e-mail | index | archive | help
* Ullasan Kottummal <ullasan.kottummal@uk.zurich.com> [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
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?20010803130722.D85642>