how to know other side of a named pipe has been opened - Unix

This is a discussion on how to know other side of a named pipe has been opened - Unix ; Hello, I am opening a Named Pipe for reading in nonblocking mode from one process. Because non blocking open of the named pipe returns immediately, whether or not the other side of the pipe is opened for writing, then how ...

+ Reply to Thread
Results 1 to 6 of 6

Thread: how to know other side of a named pipe has been opened

  1. how to know other side of a named pipe has been opened

    Hello,

    I am opening a Named Pipe for reading in nonblocking mode from one
    process. Because non blocking open of the named pipe returns
    immediately, whether or not the other side of the pipe is opened for
    writing, then how to know when the other side is opened for writing.


    Process
    A
    Process B

    Open Named Pipe for reading in Non blocking
    mode After some arbitrary time opens the

    Named Pipe for writing.

    Open returns immediately.

    for writing?>

    Thanks in advance.
    Jois


  2. Re: how to know other side of a named pipe has been opened

    On Jun 5, 2:08 am, Lakshmipathy.j...@gmail.com wrote:
    > Hello,
    >
    > I am opening a Named Pipe for reading in nonblocking mode from one
    > process. Because non blocking open of the named pipe returns
    > immediately, whether or not the other side of the pipe is opened for
    > writing, then how to know when the other side is opened for writing.
    >
    > Process
    > A
    > Process B
    >
    > Open Named Pipe for reading in Non blocking
    > mode After some arbitrary time opens the
    >
    > Named Pipe for writing.
    >
    > Open returns immediately.
    >
    > > for writing?>
    >

    You can have a try on select().

    --
    I want to do language-exchange, I am seeking an English native speaker
    to talk with me about Linux, freedom software, UNIX programming etc.
    Skype: abai_1982


  3. Re: {"MSG_f8d8bead972691a4":{},"msgIds":["MSG_f8d8bead972691a4"]}

    On Jun 4, 4:23 pm, Bin Chen wrote:
    > On Jun 5, 2:08 am, Lakshmipathy.j...@gmail.com wrote:
    >
    >
    >
    > > Hello,

    >
    > > I am opening a Named Pipe for reading in nonblocking mode from one
    > > process. Because non blocking open of the named pipe returns
    > > immediately, whether or not the other side of the pipe is opened for
    > > writing, then how to know when the other side is opened for writing.

    >
    > > Process
    > > A
    > > Process B

    >
    > > Open Named Pipe for reading in Non blocking
    > > mode After some arbitrary time opens the

    >
    > > Named Pipe for writing.

    >
    > > Open returns immediately.

    >
    > > > > for writing?>

    >
    > You can have a try on select().
    >
    > --
    > I want to do language-exchange, I am seeking an English native speaker
    > to talk with me about Linux, freedom software, UNIX programming etc.
    > Skype: abai_1982- Hide quoted text -
    >
    > - Show quoted text -


    Hi,
    Thanks a lot for replying.

    If I use select on the named pipe descriptor, then select will tell me
    when the data is ready on the named pipe for reading.
    But what I want to know is, when the other side of the named pipe has
    been opened.

    If I open the named pipe for reading in blocking mode, then the open
    call will block untill the other side of the named pipe is opened for
    writing.
    If the named pipe is opened for reading in the non blocking mode, then
    open returns immediately, even though the other side is not opened. So
    in such a case,
    I want to know, when the other side of the named pipe is opened for
    writing.

    Thanks,
    Jois


  4. Re: {"MSG_f8d8bead972691a4":{},"msgIds":["MSG_f8d8bead972691a4"]}

    On Jun 4, 11:37 pm, Lakshmipathy.j...@gmail.com wrote:
    > On Jun 4, 4:23 pm, Bin Chen wrote:
    >
    >
    >
    > > On Jun 5, 2:08 am, Lakshmipathy.j...@gmail.com wrote:

    >
    > > > Hello,

    >
    > > > I am opening a Named Pipe for reading in nonblocking mode from one
    > > > process. Because non blocking open of the named pipe returns
    > > > immediately, whether or not the other side of the pipe is opened for
    > > > writing, then how to know when the other side is opened for writing.

    >
    > > > Process
    > > > A
    > > > Process B

    >
    > > > Open Named Pipe for reading in Non blocking
    > > > mode After some arbitrary time opens the

    >
    > > > Named Pipe for writing.

    >
    > > > Open returns immediately.

    >
    > > > > > > for writing?>

    >
    > > You can have a try on select().

    >
    > > --
    > > I want to do language-exchange, I am seeking an English native speaker
    > > to talk with me about Linux, freedom software, UNIX programming etc.
    > > Skype: abai_1982- Hide quoted text -

    >
    > > - Show quoted text -

    >
    > Hi,
    > Thanks a lot for replying.
    >
    > If I use select on the named pipe descriptor, then select will tell me
    > when the data is ready on the named pipe for reading.
    > But what I want to know is, when the other side of the named pipe has
    > been opened.
    >
    > If I open the named pipe for reading in blocking mode, then the open
    > call will block untill the other side of the named pipe is opened for
    > writing.
    > If the named pipe is opened for reading in the non blocking mode, then
    > open returns immediately, even though the other side is not opened. So
    > in such a case,
    > I want to know, when the other side of the named pipe is opened for
    > writing.
    >
    > Thanks,
    > Jois


    You can only asynchronously know when data is available on a named
    pipe. UNIX named pipes do not work like Windoze named pipes, which
    are more like connected sockets -- one STREAM per connect. You can
    use fcntl(FIONREAD) to determine if data is available on the named
    pipe file descriptor and read it.

    However, your real problems after the first "client" connection closes
    its side of the named. The "server" side of the named pipe -- your
    server -- will always be "read ready", however the FIONREAD will still
    report bytes correctly.

    Also note that a named pipe is a STREAM, i.e. no delimiters between
    messages. You will need to either use a begin/end message delimiters
    or byte(s) for length of message to digest discrete client messages.

    cj


  5. Re: {"MSG_f8d8bead972691a4":{},"msgIds":["MSG_f8d8bead972691a4"]}

    On Jun 5, 3:53 pm, CJ wrote:
    > On Jun 4, 11:37 pm, Lakshmipathy.j...@gmail.com wrote:
    >
    >
    >
    >
    >
    > > On Jun 4, 4:23 pm, Bin Chen wrote:

    >
    > > > On Jun 5, 2:08 am, Lakshmipathy.j...@gmail.com wrote:

    >
    > > > > Hello,

    >
    > > > > I am opening a Named Pipe for reading in nonblocking mode from one
    > > > > process. Because non blocking open of the named pipe returns
    > > > > immediately, whether or not the other side of the pipe is opened for
    > > > > writing, then how to know when the other side is opened for writing.

    >
    > > > > Process
    > > > > A
    > > > > Process B

    >
    > > > > Open Named Pipe for reading in Non blocking
    > > > > mode After some arbitrary time opens the

    >
    > > > > Named Pipe for writing.

    >
    > > > > Open returns immediately.

    >
    > > > > > > > > for writing?>

    >
    > > > You can have a try on select().

    >
    > > > --
    > > > I want to do language-exchange, I am seeking an English native speaker
    > > > to talk with me about Linux, freedom software, UNIX programming etc.
    > > > Skype: abai_1982- Hide quoted text -

    >
    > > > - Show quoted text -

    >
    > > Hi,
    > > Thanks a lot for replying.

    >
    > > If I use select on the named pipe descriptor, then select will tell me
    > > when the data is ready on the named pipe for reading.
    > > But what I want to know is, when the other side of the named pipe has
    > > been opened.

    >
    > > If I open the named pipe for reading in blocking mode, then the open
    > > call will block untill the other side of the named pipe is opened for
    > > writing.
    > > If the named pipe is opened for reading in the non blocking mode, then
    > > open returns immediately, even though the other side is not opened. So
    > > in such a case,
    > > I want to know, when the other side of the named pipe is opened for
    > > writing.

    >
    > > Thanks,
    > > Jois

    >
    > You can only asynchronously know when data is available on a named
    > pipe. UNIX named pipes do not work like Windoze named pipes, which
    > are more like connected sockets -- one STREAM per connect. You can
    > use fcntl(FIONREAD) to determine if data is available on the named
    > pipe file descriptor and read it.
    >
    > However, your real problems after the first "client" connection closes
    > its side of the named. The "server" side of the named pipe -- your
    > server -- will always be "read ready", however the FIONREAD will still
    > report bytes correctly.
    >
    > Also note that a named pipe is a STREAM, i.e. no delimiters between
    > messages. You will need to either use a begin/end message delimiters
    > or byte(s) for length of message to digest discrete client messages.
    >
    > cj- Hide quoted text -
    >
    > - Show quoted text -


    Hi CJ,

    Thanks, a lot for the explanation. Your note clarified my question abt
    named pipe usage.
    Just out of interest I am asking, why can't it be made that UNIX
    named pipes can be
    asynchronously known when its other side is opened for writing. Are
    there any system limitations,
    that prevents it to be done like that?

    Thanks a lot,
    Jois


  6. Re: {"MSG_f8d8bead972691a4":{},"msgIds":["MSG_f8d8bead972691a4"]}

    On Jun 5, 10:37 pm, Lakshmipathy.j...@gmail.com wrote:
    > On Jun 5, 3:53 pm, CJ wrote:
    >
    >
    >
    > > On Jun 4, 11:37 pm, Lakshmipathy.j...@gmail.com wrote:

    >
    > > > On Jun 4, 4:23 pm, Bin Chen wrote:

    >
    > > > > On Jun 5, 2:08 am, Lakshmipathy.j...@gmail.com wrote:

    >
    > > > > > Hello,

    >
    > > > > > I am opening a Named Pipe for reading in nonblocking mode from one
    > > > > > process. Because non blocking open of the named pipe returns
    > > > > > immediately, whether or not the other side of the pipe is opened for
    > > > > > writing, then how to know when the other side is opened for writing.

    >
    > > > > > Process
    > > > > > A
    > > > > > Process B

    >
    > > > > > Open Named Pipe for reading in Non blocking
    > > > > > mode After some arbitrary time opens the

    >
    > > > > > Named Pipe for writing.

    >
    > > > > > Open returns immediately.

    >
    > > > > > > > > > > for writing?>

    >
    > > > > You can have a try on select().

    >
    > > > > --
    > > > > I want to do language-exchange, I am seeking an English native speaker
    > > > > to talk with me about Linux, freedom software, UNIX programming etc.
    > > > > Skype: abai_1982- Hide quoted text -

    >
    > > > > - Show quoted text -

    >
    > > > Hi,
    > > > Thanks a lot for replying.

    >
    > > > If I use select on the named pipe descriptor, then select will tell me
    > > > when the data is ready on the named pipe for reading.
    > > > But what I want to know is, when the other side of the named pipe has
    > > > been opened.

    >
    > > > If I open the named pipe for reading in blocking mode, then the open
    > > > call will block untill the other side of the named pipe is opened for
    > > > writing.
    > > > If the named pipe is opened for reading in the non blocking mode, then
    > > > open returns immediately, even though the other side is not opened. So
    > > > in such a case,
    > > > I want to know, when the other side of the named pipe is opened for
    > > > writing.

    >
    > > > Thanks,
    > > > Jois

    >
    > > You can only asynchronously know when data is available on a named
    > > pipe. UNIX named pipes do not work like Windoze named pipes, which
    > > are more like connected sockets -- one STREAM per connect. You can
    > > use fcntl(FIONREAD) to determine if data is available on the named
    > > pipe file descriptor and read it.

    >
    > > However, your real problems after the first "client" connection closes
    > > its side of the named. The "server" side of the named pipe -- your
    > > server -- will always be "read ready", however the FIONREAD will still
    > > report bytes correctly.

    >
    > > Also note that a named pipe is a STREAM, i.e. no delimiters between
    > > messages. You will need to either use a begin/end message delimiters
    > > or byte(s) for length of message to digest discrete client messages.

    >
    > > cj- Hide quoted text -

    >
    > > - Show quoted text -

    >
    > Hi CJ,
    >
    > Thanks, a lot for the explanation. Your note clarified my question abt
    > named pipe usage.
    > Just out of interest I am asking, why can't it be made that UNIX
    > named pipes can be
    > asynchronously known when its other side is opened for writing. Are
    > there any system limitations,
    > that prevents it to be done like that?
    >
    > Thanks a lot,
    > Jois


    Pipes in UNIX function to create streams of data flowing through a
    series of applications, i.e. ps -ef |egrep "something"|sed -e
    "something else"|etc. This makes them also good for simple one-way
    IPC, all that is needed is a common "well known port" address, i.e. a
    filesystem name, so clients can "resolve" the servers "listen port."
    But, since clients at some point need something back from their
    servers, a unidirectional pipe is of little help.

    I am only guessing as to why pipes, named or unnamed, were designed to
    function as they do.

    You may want to look at Unix Domain Sockets, PF_UNIX. These too are
    filesystem entities, but work like and IP socket, i.e. you accept each
    connection. Unix Domain Sockets are "like" Windoze named pipes in
    functionality -- somewhat, at least.

    cj


+ Reply to Thread