This is the mail archive of the cygwin@sourceware.cygnus.com mailing list for the Cygwin project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]

Re: select()


You are right Harry I should send the code, but I haven't wittled it down 
to a small example yet. I was hoping that the description of the problem 
would cause someone to say "yeah here's the stupid little mistake you are 
making, I did that once..."

I will probably come up with a concise example and send it next.

Here's the other strange stuff that I think are clues:

1. My server side program will not get anythin until I press a key
   in its window. It doesn't have to be a character key, just shift will do.
   It is as though it is blocked and thinks there is not input
   until that keypress. Then after that it thinks there is always data
   hence select() always returns ready.

2. If I close fd's 0 and 1, I don't need the keypress of #1 above.
   But then select returns with -1 right away.

Any ideas? Even if this is my stupid mistake somewhere, how can I be the 
first to make this mistake?

Thanks, 
Todd


On Fri, 9 Oct 1998, Harry Broomhall wrote:

> Todd M. Grimm said:
> > 
> > I am using select() to test whether there are bytes on a socket to read 
> > without blocking my program to check on this.
> > 
> > The problem is that even when there is no data it returns a 1 to say that 
> > there is data. This causes my program to try a read which blocks because 
> > there really is no data.
> > 
> > I saw several messages in the archives of this list about this, but all I 
> > could find were questions. No one ever seemed to answer the question.
> > 
> > Please let me know if you know how to get select() to work right or if 
> > there is a nother way to test for bytes without blocking.
> 
>   Without seeing the code it is impossible to judge what is
> happening, but in general, select returns whether a socket is
> *ready*, not just readable.  For example, if the other end has
> closed the connection select() will return that the socket is
> ready.  A read on the socket will return 0 to indicate the
> close.
> 
>   Regards,
>       Harry.
> 
-
For help on using this list (especially unsubscribing), send a message to
"gnu-win32-request@cygnus.com" with one line of text: "help".


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]