ipc in java

Discussion in 'Java' started by tom fredriksen, Mar 21, 2006.

  1. Does there exists any ipc mechanisms in java similar to what is
    available in os's, such as pipes, shared memory etc. or is the only ipc
    in java sockets and files?

    /tom
     
    tom fredriksen, Mar 21, 2006
    #1
    1. Advertising

  2. tom fredriksen

    Roedy Green Guest

    On Tue, 21 Mar 2006 03:12:27 +0100, tom fredriksen <>
    wrote, quoted or indirectly quoted someone who said :

    >
    >Does there exists any ipc mechanisms in java similar to what is
    >available in os's, such as pipes, shared memory etc. or is the only ipc
    >in java sockets and files?


    see http://mindprod.com/jgloss/remoteio.html
    for a catalog of the tools. The main one is RMI. See
    http://mindprod.com/jgloss/rmi.html
    --
    Canadian Mind Products, Roedy Green.
    http://mindprod.com Java custom programming, consulting and coaching.
     
    Roedy Green, Mar 21, 2006
    #2
    1. Advertising

  3. tom fredriksen

    Roedy Green Guest

    Roedy Green, Mar 21, 2006
    #3
  4. tom fredriksen wrote:
    > Does there exists any ipc mechanisms in java


    J2SE?

    > similar to what is
    > available in os's, such as pipes, shared memory etc.


    No, although using named pipes via the Files class often works.

    > or is the only ipc
    > in java sockets and files?


    Plus things on top of it, like CORBA and RMI. In J2EE you have things
    like SOAP support (SAAJ, JAX-RPC).

    But it is likely that you can find a JNI-based third party
    implementation for almost every OS-specific IPC mechanism.


    /Thomas
    --
    The comp.lang.java.gui FAQ:
    ftp://ftp.cs.uu.nl/pub/NEWS.ANSWERS/computer-lang/java/gui/faq
    http://www.uni-giessen.de/faq/archiv/computer-lang.java.gui.faq/
     
    Thomas Weidenfeller, Mar 21, 2006
    #4
  5. Thomas Weidenfeller wrote:
    > tom fredriksen wrote:
    >
    > But it is likely that you can find a JNI-based third party
    > implementation for almost every OS-specific IPC mechanism.


    I found one package which implemented posix ipc, "posix for java"

    http://www.bmsi.com/java/posix/package.html


    In any case it was more a question of curiosity as I had never heard of
    it. I was thinking that some simple and common version of a couple
    mechanisms could perhaps have been implemented java, if it could be an
    abstracted implementation of what exists in current OS's. But I realise
    that a hindrance is that java is not process oriented but rather thread
    oriented. Which makes it a bit awkward to use.

    /tom
     
    tom fredriksen, Mar 21, 2006
    #5
  6. tom fredriksen

    EJP Guest

    Roedy Green wrote:

    > http://mindprod.com/jgloss/remotefileaccess.html


    and to this extensive list should be added java.nio.channels.Pipe. These
    are not named pipes, they are more like Unix inter-process pipes (i.e. a
    read pipe and a write pipe), but they are implemented under the hood
    with sockets (as I believe Unix pipes are too actually).
     
    EJP, Mar 21, 2006
    #6
  7. tom fredriksen

    Roedy Green Guest

    On Tue, 21 Mar 2006 23:25:26 GMT, EJP
    <> wrote, quoted or indirectly quoted
    someone who said :

    >> http://mindprod.com/jgloss/remotefileaccess.html

    >
    >and to this extensive list should be added java.nio.channels.Pipe.


    done.
    --
    Canadian Mind Products, Roedy Green.
    http://mindprod.com Java custom programming, consulting and coaching.
     
    Roedy Green, Mar 22, 2006
    #7
  8. tom fredriksen

    Nigel Wade Guest

    EJP wrote:

    > Roedy Green wrote:
    >
    >> http://mindprod.com/jgloss/remotefileaccess.html

    >
    > and to this extensive list should be added java.nio.channels.Pipe. These
    > are not named pipes, they are more like Unix inter-process pipes (i.e. a
    > read pipe and a write pipe), but they are implemented under the hood
    > with sockets (as I believe Unix pipes are too actually).


    IIRC a pipe is equivalent to a socket in the UNIX domain rather than the INET
    domain, and yes they use sockets. Because the sockets are in the UNIX (local)
    domain a pipe is only available for IPC on the same host, there is no network
    involvement. It's really only of use in communicating between parent/child
    processes as the pipe has no ability to listen for connections. Both ends of
    the socket are established when the pipe is created, within a single process.

    Also, a pipe is uni-directional. To have 2-way communication requires two pipes.


    --
    Nigel Wade, System Administrator, Space Plasma Physics Group,
    University of Leicester, Leicester, LE1 7RH, UK
    E-mail :
    Phone : +44 (0)116 2523548, Fax : +44 (0)116 2523555
     
    Nigel Wade, Mar 22, 2006
    #8
  9. Nigel Wade wrote:
    > IIRC a pipe is equivalent to a socket in the UNIX domain rather than the INET
    > domain, and yes they use sockets.


    This all depends on the type of Unix pipe you are talking about, and on
    the heritage of the particular Unix version.

    Classic Unix pipes need not use sockets at all. In SVR4 these ones are
    implemented on top of the streams io framework. In older AT&T Unix
    version it was just some particular code in the kernel.

    So called stream pipes are socked-based in BSD Unix systems, and simply
    pipes-based in SVR4.

    Regarding SVR4,

    > Also, a pipe is uni-directional. To have 2-way communication requires two pipes.


    here the normal pipe is already bi-directional (due to the
    implementation on top of the streams io framework). When you ask for a
    pipe, you always get a bi-directional one in SVR4. While on BSD systems
    you have to ask for a socket pair to get a bi-directional one (or use
    two normal pipes).

    Of course, there are for sure Unix dialects where this is done differently.

    And you of course also have named pipes (FIFOs) and you can associate a
    name with a stream pipe.

    /Thomas
    --
    The comp.lang.java.gui FAQ:
    ftp://ftp.cs.uu.nl/pub/NEWS.ANSWERS/computer-lang/java/gui/faq
    http://www.uni-giessen.de/faq/archiv/computer-lang.java.gui.faq/
     
    Thomas Weidenfeller, Mar 22, 2006
    #9
  10. tom fredriksen

    Nigel Wade Guest

    Thomas Weidenfeller wrote:

    > Nigel Wade wrote:
    >> IIRC a pipe is equivalent to a socket in the UNIX domain rather than the INET
    >> domain, and yes they use sockets.

    >
    > This all depends on the type of Unix pipe you are talking about, and on
    > the heritage of the particular Unix version.
    >
    > Classic Unix pipes need not use sockets at all. In SVR4 these ones are
    > implemented on top of the streams io framework. In older AT&T Unix
    > version it was just some particular code in the kernel.
    >
    > So called stream pipes are socked-based in BSD Unix systems, and simply
    > pipes-based in SVR4.


    It's been a while since I did any programming requiring pipes. In those days the
    pipe system call returned a pair of file descriptors, one for read and one for
    write. It was the responsibility of the programmer to ensure that the correct
    end of each was closed in the parent/child to allow correct communications.

    As in all fields, progress has been made (but not necessarily in the
    documentation). According to the man pages for Linux/IRIX/Solaris the pipe
    system call still returns a classic, uni-directional pipe. To further confuse
    matters IRIX implements 2 versions of pipe, one with the conventional SVR3.2
    uni-directional semantics and another with the bi-directional SVR4 semantics,
    controlled either by a kernel tunable parameter, or the library linked at
    runtime.

    Which type of pipe is really returned remains a mystery...

    >
    > Regarding SVR4,
    >
    >> Also, a pipe is uni-directional. To have 2-way communication requires two

    pipes.
    >
    > here the normal pipe is already bi-directional (due to the
    > implementation on top of the streams io framework). When you ask for a
    > pipe, you always get a bi-directional one in SVR4. While on BSD systems
    > you have to ask for a socket pair to get a bi-directional one (or use
    > two normal pipes).



    Sorry, what I meant to say was that Pipe is uni-directional. According to the
    API Javadocs it implements a uni-directional pipe.

    --
    Nigel Wade, System Administrator, Space Plasma Physics Group,
    University of Leicester, Leicester, LE1 7RH, UK
    E-mail :
    Phone : +44 (0)116 2523548, Fax : +44 (0)116 2523555
     
    Nigel Wade, Mar 23, 2006
    #10
  11. Nigel Wade wrote:
    > As in all fields, progress has been made (but not necessarily in the
    > documentation). According to the man pages for Linux/IRIX/Solaris the pipe
    > system call still returns a classic, uni-directional pipe.


    Solaris has bi-directional pipes. From the Solaris 8 pipe(2) man page
    (Solaris has its roots in SVR4):

    | The files associated with fildes[0] and fildes[1] are streams
    | and are both opened for reading and writing.
    | ...
    | Since a pipe is bi-directional,

    /Thomas

    --
    The comp.lang.java.gui FAQ:
    ftp://ftp.cs.uu.nl/pub/NEWS.ANSWERS/computer-lang/java/gui/faq
    http://www.uni-giessen.de/faq/archiv/computer-lang.java.gui.faq/
     
    Thomas Weidenfeller, Mar 23, 2006
    #11
  12. tom fredriksen

    Nigel Wade Guest

    Thomas Weidenfeller wrote:

    > Nigel Wade wrote:
    >> As in all fields, progress has been made (but not necessarily in the
    >> documentation). According to the man pages for Linux/IRIX/Solaris the pipe
    >> system call still returns a classic, uni-directional pipe.

    >
    > Solaris has bi-directional pipes. From the Solaris 8 pipe(2) man page
    > (Solaris has its roots in SVR4):
    >
    > | The files associated with fildes[0] and fildes[1] are streams
    > | and are both opened for reading and writing.
    > | ...
    > | Since a pipe is bi-directional,
    >
    > /Thomas
    >


    Ah, there's obviously been a change. The Solaris version I have (for
    compatibility reasons) is 2.7. I can't remember whether pipe() does actually
    return bi-directional pipes or not. It might be that in 2.7 you have to
    specifically request them, as in IRIX where you need to link with -lnsl, or
    just that the man page hadn't been updated (I have a vague recollection it
    might be the latter, but it's some time since I used pipes on Solaris).


    --
    Nigel Wade, System Administrator, Space Plasma Physics Group,
    University of Leicester, Leicester, LE1 7RH, UK
    E-mail :
    Phone : +44 (0)116 2523548, Fax : +44 (0)116 2523555
     
    Nigel Wade, Mar 24, 2006
    #12
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. piyush
    Replies:
    0
    Views:
    1,853
    piyush
    Jul 14, 2004
  2. gary
    Replies:
    3
    Views:
    545
    Steve Grazzini
    Sep 18, 2003
  3. Day9901

    Java IPC

    Day9901, Feb 7, 2004, in forum: Java
    Replies:
    1
    Views:
    670
    Andrew Thompson
    Feb 7, 2004
  4. Gordon Beaton

    Java IPC Query

    Gordon Beaton, Nov 30, 2005, in forum: Java
    Replies:
    4
    Views:
    3,382
    Roedy Green
    Dec 1, 2005
  5. Replies:
    3
    Views:
    1,731
    Michael Rauscher
    Aug 20, 2006
Loading...

Share This Page