I have a c# namedpipe server created like so:
NamedPipeServerStream pipeServer = new NamedPipeServerStream(IVConstants.PIPENAME, PipeDirection.InOut);
pipeServer.WaitForConnection();
pipeWriter = new StreamWriter(pipeServer);
pipeWriter.AutoFlush = true;
try
{
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");
while(true)
{
String received = pipe.readLine();
processEvent(received);
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
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 =)