Glstunna Glstunna - 4 months ago 18x
Java Question

Namedpipe hangs when sending large string

I have a c# namedpipe server created like so:

NamedPipeServerStream pipeServer = new NamedPipeServerStream(IVConstants.PIPENAME, PipeDirection.InOut);
pipeWriter = new StreamWriter(pipeServer);
pipeWriter.AutoFlush = true;

pipeWriter.WriteLine("You are Connected!!!");
catch (IOException e)
Console.WriteLine("ERROR: {0}", e.Message);

Writing out small strings like the one above gives no problem.
However when I start chugging out huge strings e.g 1500 chars, the pipe hangs and stays hung until I kill the client it is trying to send something to. The client is a java app.
I see that is DOES send stuff to the client, after-which the hang happens.

The client is a Java app receiving with this:

RandomAccessFile pipe = new RandomAccessFile("\\\\.\\pipe\\mypipe", "rw");

String received = pipe.readLine();
System.out.println("Response: " + received );

The client doesn't throw an exception, and I can see the System.out after the readline().
So what gives?


Bah! Pure foolishness on my part. It seems something was hanging in


I thought it was getting to

System.out.println("Response: " + received );

But it wasn't. processEvent(...) had a duplicate System.out.println("Response: " + received ); in it, hence my confusion. It had nothing to do with the namedpipe after-all.

Thanks guys =)