Results 1 to 3 of 3

Thread: IO handling

  1. #1
    sonalim is offline Member
    Join Date
    Oct 2010
    Posts
    2
    Rep Power
    0

    Default IO handling

    Hi,

    I'm in a big mess and kindly need your advices(and it's kind of urgent too)..

    I have written a Named Pipe client in java where the Named Pipe server is in C++ and cannot be modified. In the client, i have used java's "RandomAccessFile" to create a bidirectional pipe to the server.

    From another class a separate thread is continuously trying to read the Named Pipe Client where the main thread tries to write to the Named Pipe Client when required.

    In the ideal situation i want the Named Pipe Client's read method to return -1 or null when there in no incoming stream from the server and sleep for 100ms (which will allow the main thread to perform write operations if required) and then go for the next iteration of listening. Or at-least implementing a timeout for the read function is required.

    I can not change the server/client communication to sockets since server is already implemented in C++ and can not be altered.

    Please give me a hit to solve this...
    Thanks!

  2. #2
    travishein's Avatar
    travishein is offline Senior Member
    Join Date
    Sep 2009
    Location
    Canada
    Posts
    684
    Rep Power
    6

    Default

    I didn't know you could both read and write from / to a named pipe. I thought a pipe would be written to by one process and read from by a second process, so that reading and writing would be achieved by having two pipes, one from p1 -> p2 and one from p2 -> p1. where one process always writes to and the other process always reads from a given pipe.

  3. #3
    sonalim is offline Member
    Join Date
    Oct 2010
    Posts
    2
    Rep Power
    0

    Default

    I implemented 2 pipe approach first. Since my server was implemented in C++ which uses handles, the server identified it as 2 separate clients. So in that case i couldn't receive the response from the server for my named pipe client's write operation.

    So i went for bidirectional pipe using "RandomAccessFile" (taking into account that pipes behave just as files) in java. Now i have got this issue that i can't timeout the read operation :(.

Similar Threads

  1. Regarding File Handling
    By ravjot28 in forum New To Java
    Replies: 1
    Last Post: 01-20-2010, 09:15 PM
  2. Exception Handling...
    By focus_nitin in forum New To Java
    Replies: 1
    Last Post: 02-16-2008, 03:13 AM
  3. SQL error handling example
    By Java Tip in forum Java Tip
    Replies: 0
    Last Post: 02-12-2008, 09:38 AM
  4. Event Handling
    By luisarca in forum Sun Java Wireless Toolkit
    Replies: 5
    Last Post: 05-07-2007, 06:05 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •