[jcifs] Problem reading multiple writes from named pipe

Eric Sword ericsword at grouplogic.com
Tue Apr 8 07:01:38 EST 2003


I am having a problem reading data from a pipe when it was written using
more than one WriteFile call in a C++ app.  The setup is pretty standard
- I'm am using slightly modified copies of the sample apps createnp and
CallNamedPipe.  The Java app reads from stdin, sends to the C++ app, and
the C++ app echos it back in 2 sends.  The first send contains only an
int which is the length of the second send (matching an existing
protocol I am working with).  

I have tried multiple ways of setting up the pipe (just PIPE_TYPE_RDWR,
PIPE_TYPE_RDWR | PIPE_TYPE_CALL, and PIPE_TYPE_RDWR |
PIPE_TYPE_TRANSACT), properly changing the pipe URL for each.  Each way,
I can send data over the pipe just fine and I get back the int from the
first send, but block indefinitely waiting for the info from the second
message.

[code snippet]

//first read the length of the message - stored in the first 4 bytes
length = sd_istream.readInt();
System.out.println("Message Length: " + length);

//now read the message
int numRead = in.read(temp);
String tempString = new String(temp, 0, numRead);

[end snippet]

If I just do the single in.read, it will also only find 4 bytes to read
in.  

Suggestions?

Thanks,

e

---
Eric Sword
Director of Professional Services
Group Logic, Inc.
ericsword at grouplogic.com
800.476.8781 (800.GROUP81)
http://www.grouplogic.com/services/




More information about the jcifs mailing list