Use of select() to poll a file (device)
Richard Danter
radanter at googlemail.com
Thu Nov 1 13:59:39 PDT 2007
Hi all,
I am new to wxWidgets and have a couple of questions. I will place
them in separate mails as they are quite different.
I am using wxWidgets (wxGTK) 2.8.x (various values of x) on several
Linux hosts (Ubuntu, SuSE, RedHat). My application should also work
with wxMotif and on Solaris. Possibly Windows one day too.
First question is this: without polling, how can I know when data is
ready in a file. In the past I have used something like this:
FD_ZERO( &fdset );
FD_SET( serfn, &fdset );
rc = select( serfn+1, &fdset, NULL, NULL, NULL );
/* Char ready at serial port? */
if ( FD_ISSET( serfn, &fdset ) )
{
sh = serial_getchar();
putchar( sh );
fflush( stdout );
}
within a while(1) loop. How can I do this within the wxWidgets event loop?
Thanks
Rich
More information about the wx-users
mailing list