select() returns 1 but fails

select() returns 1 but fails

Post by Greg » Sat, 06 Jul 2002 19:01:49



Hi

I have a multithreaded socket program doing non blocking select() in
C++ running on FreeBSD.

I'm using the connect_nonb() function in figure 15.11, page 411 in
UNIX Network Programming, Networking APIs: Sockets and XTI, Volume 1,
Second Editon, by W. Richard Stevens.

After running for a time with a lot of traffic going over the sockets,
my program reaches the err_quit() function in line 34.

I'm looking for ideas of what could cause this to happen, or good ways
of debugging what's going on.

Thanks,
G Z

 
 
 

select() returns 1 but fails

Post by David Schwart » Sun, 07 Jul 2002 02:47:29



> After running for a time with a lot of traffic going over the sockets,
> my program reaches the err_quit() function in line 34.

        What error are you getting and what function are you getting it from?

        DS

 
 
 

select() returns 1 but fails

Post by Barry Margoli » Sun, 07 Jul 2002 04:51:55





>> After running for a time with a lot of traffic going over the sockets,
>> my program reaches the err_quit() function in line 34.

>    What error are you getting and what function are you getting it from?

Did you read the code in question -- he gave a book and page number.  It
performs select() on a single descriptor, putting it in both the read and
write sets.  But when select() returns > 0, indicating that the descriptor
should be ready, FD_ISSET() isn't true for it in either set.

--

Genuity, Woburn, MA
*** DON'T SEND TECHNICAL QUESTIONS DIRECTLY TO ME, post them to newsgroups.
Please DON'T copy followups to me -- I'll assume it wasn't posted to the group.

 
 
 

1. Does select() return if the FD changed before select() was called?

Does a select() call return if the file descriptor it is watching changed
before the select() was called if the file descriptor hasn't been read or
written to since the change? For an illustration:

while ( select() ) {
    //Do some stuff here
    //One of the file descriptors select() watches happens to change right
here
    //Do some more stuff

Will select return on the next while() iteration because of the file
descriptor that changed in the middle of the loop? Or will it only watch for
descriptors that change since the select() call was made, which means my
program would block in select() without noticing the change that happened in
the last loop?

The man page doesn't seem to say much about this.

Also, if anyone can recommend any good books on programming TCP
clients/servers on POSIX and/or Win32 systems I'd appreciate it.

LKembel

2. Open File Descriptor Question

3. Select returns data available read returns no data

4. Cygwin scroll bar

5. When do read() return 0 despite that select() returned 1

6. Yggdrasil Linux

7. Solaris 2.5.1 installpatch failed, return code 5, pkgadd failed

8. smb vs. nfs

9. select() returns error ECHILD

10. select() doesn't return on socket descriptor

11. No child process returned as error from connec and select

12. Q: select() returns upon socket connection, or STDIN, but not both

13. socket accept error! as select returns -1