turtlemaster
Programmer
I am developing an application that will communicate with another application (that I am not developing) using named pipes. So in the mean time I am developing a simulator app that will only preform the communication portion so I can work out the details. The problem is timing I think. From all of the documentation I have read the you must;
Server:
1) create the pipe (on the server -- which in this case is the same machine)
2) connect to the pipe
3) loop to read and write data
Client:
1) waitnamedpipe with same pipe name
2) createfile with same as pipe name
3) loop to write and read data
I was having problems with the client not creating the pipe but now it seems to be working fine. The client is creating the pipe and then looping and peeking named pipe until data has arrived. In the meantime the server is trying to connect to the pipe (which fails unless there is a client connected). Even though the client is connecting the server is returning the error 536 indefinently. I have read the microsoft online docs and an error should occur but the lastdllerror should be ERROR_PIPE_CONNECTED (which really isn't and error).
How can I have the simulator application wait until the there is a client connected at the other end. I have tried looping until err.lastdllerror is not error_pipe_listening (536) and waitforsingleobject and waitforsingleobjectex but these do not return when a client has connected. The example microsoft provides (which is in C) seems to loop until the state changes then connect and send data
Any help would be greatly appreciated!! Thanks.
Server:
1) create the pipe (on the server -- which in this case is the same machine)
2) connect to the pipe
3) loop to read and write data
Client:
1) waitnamedpipe with same pipe name
2) createfile with same as pipe name
3) loop to write and read data
I was having problems with the client not creating the pipe but now it seems to be working fine. The client is creating the pipe and then looping and peeking named pipe until data has arrived. In the meantime the server is trying to connect to the pipe (which fails unless there is a client connected). Even though the client is connecting the server is returning the error 536 indefinently. I have read the microsoft online docs and an error should occur but the lastdllerror should be ERROR_PIPE_CONNECTED (which really isn't and error).
How can I have the simulator application wait until the there is a client connected at the other end. I have tried looping until err.lastdllerror is not error_pipe_listening (536) and waitforsingleobject and waitforsingleobjectex but these do not return when a client has connected. The example microsoft provides (which is in C) seems to loop until the state changes then connect and send data
Any help would be greatly appreciated!! Thanks.