Re: Can you select() socketpair()-generated descriptors?

From: Brian Raiter (blr_at_drizzle.com)
Date: 09/29/04


Date: Wed, 29 Sep 2004 20:15:21 +0000 (UTC)


> 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



Relevant Pages

  • Re: Question on select() and sockets
    ... selectsays the descriptor is, respectively, readable or writeable: ... a 'pipe buffer' is composed of a queue of buffers of size ... taking into account that people are really ...
    (comp.unix.programmer)
  • Re: dialog - absolute beginner problems
    ... assign a value to the variable "mac". ... The dialog command needs to have its standard output set to ... But what we want redirected into the shell's pipe is not ... whatever file had descriptor 2, and set up a new descriptor 2 ...
    (comp.unix.shell)
  • Re: replacing stdin/stdout with openpty master fd
    ... A file descriptor is a hole in the wall of a process through which it ... whatever hole number 4 is connected to, and so the kernel takes the hose ... PTY box in the corner. ... If the data was already in the pipe before the ...
    (comp.unix.programmer)
  • Re: Waiting for multiple conditions
    ... > for multiple conditions in the same thread? ... descriptor 'ing thread). ... A pipe would work in this case. ... then unlock the mutex. ...
    (comp.unix.programmer)
  • Re: Question on select() and sockets
    ... selectsays the descriptor is, respectively, readable or writeable: ... a 'pipe buffer' is composed of a queue of buffers of size ... taking into account that people are really ...
    (comp.unix.programmer)