Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 308783
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 12, 20262026-05-12T07:40:56+00:00 2026-05-12T07:40:56+00:00

I use a named pipe and I want to reuse the same pipe on

  • 0

I use a named pipe and I want to reuse the same pipe on the server to allow connecting another client once the original client has disconnected. What I do is:

  • server creates a pipe using CreateNamedPipe
  • server writes data using WriteFile, and retries doing so as long as error ERROR_PIPE_LISTENING is returned (which is before any client is connected)
  • clients connects using CreateFile
  • client reads data
  • client close pipe handle using CloseHandle
  • at this point server gets error ERROR_NO_DATA when it attemps to write more data
  • server disconnects the pipe using DisconnectNamedPipe, which I hoped should make it free again
  • server tries writing data, gets error ERROR_PIPE_NOT_CONNECTED, it retries doing so until there is no error
  • however, when new client connects, and attempts CreateFile on the pipe, it gets ERROR_PIPE_BUSY

Hence, my question is: what other steps I need to do to disconnect client from the pipe properly so that a new client can connect?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-12T07:40:56+00:00Added an answer on May 12, 2026 at 7:40 am

    Experimenting with various calls, I have found following to work fine:

    In reaction to ERROR_PIPE_NOT_CONNECTED, server should perform:

      // allow connecting, no wait
      DWORD mode = PIPE_NOWAIT;
      SetNamedPipeHandleState(_callstackPipe,&mode,NULL,NULL);
      ConnectNamedPipe(_callstackPipe,NULL);
      mode = PIPE_WAIT;
      SetNamedPipeHandleState(_callstackPipe,&mode,NULL,NULL);
    

    ConnectNamedPipe makes the pipe connectable (not busy) again.

    Note: pipe state is changed temporarily to PIPE_NOWAIT, as otherwise ConnectNamedPipe blocks the server thread waiting for the client infinitely.

    Other solution could probably be to close the handle completely on the server side and open it again.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

See title. On the client side of an named pipe, I want to determine
I want to use a single font named Algerian across my whole website. So,
I have a UIWebView named wView. I want to use webViewDidFinishLoad: in my class,
I want to run tail on a named pipe to facilitate some binary logfile
I am using a named pipe for communications between two processes and want to
I am trying to write a named pipe server in C++. I have a
A Named Pipe Server is created with hPipe = CreateNamedPipe( zPipePath, PIPE_ACCESS_DUPLEX, PIPE_TYPE_BYTE |
I have different processes concurrently accessing a named pipe in Linux and I want
I want to use same database dir on my ubuntu installation as of windows
Should I use Named Pipes, or .NET Remoting to communicate with a running process

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.