Subject: Re: select()
From: [email-masked] (Todd M. Grimm)

11 Oct 1998 13:25:55 -0700
Message-ID: <Pine.SUN.3.91.981011095902.22891A-300000.cygnus.gnu-win32@grout>
References: <Pine.SUN.3.91.981009090931.7098A-300000@grout>
Mime-Version: 1.0
Content-Type: MULTIPART/MIXED; BOUNDARY="-2138520006-1113834566-908114887=:22891"
To: [email-masked]

  This message is in MIME format.  The first part should be readable text,
  while the remaining parts are likely unreadable without MIME-aware tools.
  Send mail to [email-masked] for more info.

---2138520006-1113834566-908114887=:22891
Content-Type: TEXT/PLAIN; charset=US-ASCII

Thanks to all those who responded to my select() problems. I have found my 
solution. Maybe this is what ails some of you with similar problems, 
maybe your problem is something different.

To recap, my receiving process was hanging on select() at the start even 
though there was data. When a key (even shift) was pressed in the shell 
window it would unhang and consume the already waiting data. The other 
problem was that all calls to select() after that returned with a value 
of 1 even when there was no data on the socket.

It turns out that at run-time or maybe at link time, the select() that is 
used is the unix kind that that uses the bit mask to specify what file 
descriptors are being watched. However, the include files I was using use 
some kind of Windows version that uses a structure with an array in it. 

So, when the bitmask version tried to use the structure I was passing it, 
it looked like a bitmask that wanted it to check stdin all the time. This 
explains the bad behavior. The solution is to simple use the right 
include files with the bitmask macros (FD_SET, FD_ZERO, etc.). That way 
what I build and pass really is the bitmask and it works just fine.

These are those simple little platform issues that really bite you good.

I hope this helps someone else avoid the watsed hours this cost me.

Attached are my simple demo programs that do it right now. These may be 
useful to someone looking for a starting point or to see what they do for 
includes that works.

Todd

---2138520006-1113834566-908114887=:22891
Content-Type: TEXT/PLAIN; charset=US-ASCII; name="SimpleServer.C"
Content-Transfer-Encoding: BASE64
Content-ID: <Pine.SUN.3.91.981011100807.22891B@grout>
Content-Description: 

---2138520006-1113834566-908114887=:22891
Content-Type: TEXT/PLAIN; charset=US-ASCII; name="SimpleClient.C"
Content-Transfer-Encoding: BASE64
Content-ID: <Pine.SUN.3.91.981011100807.22891C@grout>
Content-Description: 

---2138520006-1113834566-908114887=:22891--
-
For help on using this list (especially unsubscribing), send a message to
"[email-masked]" with one line of text: "help".