question on select() and sockets
Lars Henrik Mathiesen
thorinn at rimfaxe.diku.dk
Fri Nov 16 04:05:06 AEST 1990
abdik at cat.syr.EDU (Ahmad Dik) writes:
>I would like to know if select() can be used to find out if there is
>a blocked read on a socket.
It can't. And if the other end of the socket is on another machine, I
don't see how any system call could help find this info if general.
The TCP protocol has no way of getting the info, and things like UDP
much less.
>If select can not be used to tell if anyone is blocked reading on a
>socket, is there any other way I can find out ??
If it's a UNIX-domain socket, you can open /dev/mem, find your own
file descriptor for the socket, find the socket, follow its peer link
and then go through the process table to find a process that's waiting
on the peer socket's receive socket buffer. That's probably the
easiest way to do it in general.
I suggest that you arrange some other form of cooperation between the
processes. If available, semaphores might be what you're looking for.
--
Lars Mathiesen, DIKU, U of Copenhagen, Denmark [uunet!]mcsun!diku!thorinn
Institute of Datalogy -- we're scientists, not engineers. thorinn at diku.dk
More information about the Comp.unix.internals
mailing list