Works fine for me. This is from an example program in my book. Note that
connected is a Boolean which is set to true when we're connected to the
network and looking for data.:
//
// select() function from NetSocket.c
//
SWord select(SWord width, fd_set* readfds, fd_set* writefds,
fd_set* exceptfds, struct timeval*
timeout)
{
SDWord ticks;
// Convert the timeout value to ticks
if (timeout == 0) ticks = -1;
else ticks = (timeout->tv_sec * sysTicksPerSecond) +
(timeout->tv_usec / (1000000L /
sysTicksPerSecond)) ;
// call Net Lib function
return NetLibSelect(AppNetRefnum, width, readfds, writefds,
exceptfds,
ticks, &errno);
}
static void EventLoop(void)
{
Word error;
EventType event;
int nfds;
fd_set arfds, awfds, rfds, wfds;
do {
if (connected) {
nfds = 0;
FD_ZERO(&arfds);
FD_ZERO(&awfds);
FD_SET(fd, &arfds);
FD_SET(STDIN_FILENO, &arfds);
nfds = fd+1;
bcopy(&arfds, &rfds, sizeof(rfds));
bcopy(&awfds, &wfds, sizeof(wfds));
if (select(nfds, &rfds, &wfds, (fd_set*)0, (struct
timeval*)0) < 0) {
// just a signal?
if (errno == EINTR) continue;
// select error, exit application
return;
}
}
EvtGetEvent(&event, (!connected) ? evtWaitForever : 1);
if (! SysHandleEvent(&event))
if (! MenuHandleEvent(0, &event, &error))
if (! ApplicationHandleEvent(&event))
FrmDispatchEvent(&event);
} while (event.eType != appStopEvent);
}
==-
John Schettino author of
Palm OS Programming For Dummies, http://schettino.tripod.com
-----Original Message-----
From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED]]
Sent: Tuesday, December 28, 1999 11:44 AM
To: [EMAIL PROTECTED]
Subject: Using select or NetLibSelect
I was wondering if anyone has used this blocking call to wait for data on a
socket and/or input from pen or
other events.
I recall that the documentation says that select works for either stdin (pen
and
other system events) and the socket discriptor passed to it. It however does
not
seem to work properly on POSE ,it just hangs waiting for input from the
socket
completely ignoring the other events? point being, I want to write an
application that is responsive to user input while waiting for data on a
socket-
Has anyone come across this problem? any help or hints?
Arman Nikzad
iNautix Tech. Inc.