Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Named Pipes Dilemma

Status
Not open for further replies.

turtlemaster

Programmer
Oct 4, 2001
93
0
0
US
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.
 
The client doesn't create the pipe; it needs to open an already existing pipe.
 
I got that from the docs and thought that was what I was doing.

I am using the createfile API on the client end and createpipe on the server end. These functions appear to be working. It's when I try to call connectnamedpipe on the server and it keeps returning system error 536 (ERROR_PIPE_LISTENING) docs say this is because I'm trying to connect (on server end) with no client connected to the pipe.

createfile "string same as pipe name", fileread + filewrite,0,Null,0,0 'or something like that

sorry don't have exact code I am at home now.

it's a bird! ... it's a plane! ... no it's strongm!! (it seems you always come to my rescue!! -- thanks)
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top