Home > Archive > Unix Programming > September 2004 > Can you select() socketpair()-generated descriptors?
You are viewing an archived Text-only version of the thread.
To view this thread in it's original format and/or if you want to reply to
this thread please [click here]
| Author |
Can you select() socketpair()-generated descriptors?
|
|
|
| I'm pulling my hair out over trying to get a socket passed from one
process to another. My latest problem is in getting the receiving
process to detect the incoming socket. I'm using select() as I do with
all the socket descriptors and pipe descriptors, but it just times
out, as though the socket was never sent. If I create a set of
descriptors using socketpair(AF_UNIX, SOL_SOCKET, 0, desAncils), does
select() treat those descriptors the same as those created with
pipe(), accept() or connect()?
| |
| Andrew Taylor 2004-09-29, 8:07 pm |
| Jo wrote:
> I'm pulling my hair out over trying to get a socket passed from one
> process to another. My latest problem is in getting the receiving
> process to detect the incoming socket. I'm using select() as I do with
> all the socket descriptors and pipe descriptors, but it just times
> out, as though the socket was never sent. If I create a set of
> descriptors using socketpair(AF_UNIX, SOL_SOCKET, 0, desAncils), does
> select() treat those descriptors the same as those created with
> pipe(), accept() or connect()?
The second parameter to socketpair is wrong. You should be passing a
socket type (e.g. SOCK_STREAM, SOCK_DGRAM, etc.).
--
Andrew
| |
| Brian Raiter 2004-09-29, 8:07 pm |
| > I'm using select() as I do with all the socket descriptors and pipe
> descriptors, but it just times out, as though the socket was never
> sent.
It is almost certainly a bug in your code. Did you remember to set the
first argument to select() to be the value of your largest file
descriptor PLUS one? Did you remember to re-initialize your file
descriptor masks before EVERY call to select()?
> If I create a set of descriptors using socketpair(AF_UNIX,
> SOL_SOCKET, 0, desAncils), does select() treat those descriptors the
> same as those created with pipe(), accept() or connect()?
Yes. Or open(). Or the 0, 1, and 2 descriptors automatically created
for you. As far as select() is concerned, a file descriptor is a file
descriptor is a file descriptor. You can select() on all of them.
b
|
|
|
|
|