Re: A question about Named Pipe?



I have a memory that it will come out of its ReadFile with (or for async, the notification
will contain) an error indication, and the error code (e.g., via GetLastError or other
means) will be ERROR_BROKEN_PIPE. If the server disconnects the pipe, that is the end of
the session and it would make no sense to send additional information to the server via
that pipe. I'd always used an explicit end-of-data notification which one side would send
the other to indicate termination, so I never worried too much about the closure issue,
except to record errors.
joe
On Thu, 20 Oct 2005 15:52:02 -0700, "Nicky" <Nicky@xxxxxxxxxxxxxxxxxxxxxxxxx> wrote:

>
>hi,all
>I have a question about named pipe.
>How does the pipe server know the client closed the connection?
>We can refer the example for CreateNamedPipe() function in MSDN.
>In block mode, once ConnectNamedPipe() returns, it means the client called
>CreateFile(),
>and after finish reading and writing, client call CloseHandle(), at this
>point, how does the pipe server know the pipe has been closed? And if client
>did not call CloseHandle(), but not write anything to the pipe, what will be
>returned in the server side ReadFile()?
>Becuase in mostly examples, the server pipe will ReadFile(), and then
>WriteFile() back and then DisconnectNamedPipe(), what if the client needs to
>sleep 10 minutes and then send some text to server?
>Thanks.
Joseph M. Newcomer [MVP]
email: newcomer@xxxxxxxxxxxx
Web: http://www.flounder.com
MVP Tips: http://www.flounder.com/mvp_tips.htm
.



Relevant Pages

  • Re: Why is my overlapped WriteFile getting blocked? (repost)
    ... The "server bug" was that it was never ... the client would connect to the named pipe ... and get blocked on the first WriteFile. ... I ran both the client and server on the same PC and opened the client pipe ...
    (microsoft.public.win32.programmer.networks)
  • Re: Named pipe problem
    ... When the client opens a pipe on the same machine as ... the server, I get 1 pipe connect request. ... When the same client program on a different computer opens the same pipe I ... I getting 2 connection requests over a network? ...
    (microsoft.public.win32.programmer.networks)
  • Re: Named pipe problem
    ... When the client opens a pipe on the same machine as ... the server, I get 1 pipe connect request. ... When the same client program on a different computer opens the same pipe I ... I getting 2 connection requests over a network? ...
    (microsoft.public.win32.programmer.networks)
  • Multithreaded pipe server, deadlock problem
    ... I'm working on a multithreaded pipe server. ... The primary thread create name pipes and if a client is connected, it then create a thread and let the thread procedure "InstanceThread" process the clients. ... // Marker 0 ...
    (microsoft.public.win32.programmer.kernel)
  • Problem with Language monitor
    ... My project is divided into two parts one is client and other is server (which is Language Monitor DLL). ... On server side creates NamedPipe using “CreateNamedPipe” and waiting for Client connection using “ConnectNamedPipe” Win32 API’s. ... Once the connection is established ReadFile and WriteFile follows. ...
    (microsoft.public.development.device.drivers)