Named pipe in VB6: CallNamedPipe() failed with error 87
I am using CallNamedPipe() in VB6 to send messages to a C# named pipe server. On the server side the pipe is created by:
new NamedPipeServerStream(pipeName, PipeDirection.InOut, numThreads);
On the client I use this call to write 2 bytes:
Dim Header(1) As Byte
Header(0) = 0
Header(1) = 6
res = CallNamedPipe(szPipeName, Header(0), 2, bArray(0), numBytes, cbRead, 3000)
The server saw the pipe connected because WaitForConnection() did return, but then could not read any bytes. On the client side: CallNamedPipe failed and returned error code 87 (invalid pa开发者_开发技巧rameters?)
My questions are:
Is the pipe created a byte mode or message mode type? MSDN says CallNamedPipe() fails if the pipe is byte mode.
Is there a way to write to a byte mode pipe in VB6. Do I have to change the server code to create a message mode pipe?
How to get my VB6 code working?
According to the documentation, the pipe is in byte mode when you use that constructor. I don't know much about the non-.NET pipe calls, but I don't see any reason why not to set the server to a message mode pipe if the VB6 needs it.
精彩评论