willy2
05-07-2003, 06:25 AM
i am working on a POSIX compliant OS (CHORUS). this OS does not support the select system call. now i have a situation in which server dies before the client. is their any way (other than using select) for the client to find out that server is dead?
RobSeace
05-07-2003, 01:34 PM
Isn't select() actually required by POSIX these days? If so, I'm
not sure how POSIX-compliant your OS really is... ;-)
Surely, it must have something similar to check whether an FD
is readable/writable... I'm not at all familiar with that OS, so I
can't really guess what, though... I'd say look around for poll(),
but I tend to doubt it'd have poll() if it doesn't have select()... *shrug*
But, there are other ways of doing things, too... You could just
sit in a blocking read()/recv()... If the other side closes its end of
the connection, you'll get a return value of 0... If you need a
timeout limit on how long you want to wait for incoming data,
you could always use an alarm()-based timeout... (If you're
not multi-threaded, anyway...)
Another possible option is AIO/SIGIO-based I/O, too... Ie: use
fcntl()/F_SETFL/O_ASYNC (and, possibly F_SETOWN and
F_SETSIG) on the socket FD, then setup a signal handler to
do your reading for you... I don't care for AIO myself, but if I
had no select(), or equivalent, to use, it's probably the next best
thing I could think of... (Of course, who knows if your OS
supports that, either... ;-) I don't think I've ever encountered an
OS before that didn't support select()... Certainly not any one
which supported the standard Unix sockets API, anyway...
select() is such an integral part of so many sockets apps that
it kinda makes it pointless to support the API without it...)
vBulletin® v3.7.4, Copyright ©2000-2009, Jelsoft Enterprises Ltd.