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 6732863
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T10:42:03+00:00 2026-05-26T10:42:03+00:00

What bugs me when working with class NamedPipeServerStream is that for every incoming connection

  • 0

What bugs me when working with class NamedPipeServerStream is that for every incoming connection I need to create new object and call it’s method WaitForConnection.

What I want to do is to create one NamedPipeServerStream object, and then repeatedly in a while loop call aforementioned method, like that:

NamedPipeServerStream s2;
using (s2 = new NamedPipeServerStream("pipe_name", PipeDirection.InOut)) {
    while(true) {
        ss2.WaitForConnection();
        //do something here
    }
}

But when I do this, I get message

Stream has been disconnected.

Any advice?

  • 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-26T10:42:04+00:00Added an answer on May 26, 2026 at 10:42 am

    If you want to use the NamedPipeServerStream you need to work with the programming model it gives you, which is like it is because it is wrapping an underlying Windows handle to a named pipe kernel object. You can’t use it like you are trying to, because that’s not how named pipe handles work.

    If you really want to deal with connections one-at-a-time on a single thread, turn your loop inside out:

    while (true)
    {
      using (NamedPipeServerStream ss2 = new NamedPipeServerStream("pipe_name", PipeDirection.InOut)
      {
        ss2.WaitForConnection();
        // Stuff here
      }
    }  
    

    More likely, you want a multi-threaded pipe server which handles connections in parallel. If so, there are various ways – a search of other SO questions will turn up several patterns, for example here or here.

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

Sidebar

Related Questions

I am working on a class in php that is basically an interface to
I'm building a custom authentication filter class in Grails. It's working, but it bugs
I'm working on a project that has components, components have features, features have bugs.
I have a load balanced dev site that I'm working out bugs for SSL
I'm working on a small bugtracking system which shows a list of bugs. For
Findbugs bugs me about a method which opens two Closeable instances, but I can't
It bugs me to death that my viewcontroller, which happens to be a tableViewController,
It bugs me that I can't just do document.querySelectorAll(...).map(...) even in Firefox 3.6, and
One thing that bugs me about IE is that when it goes to load
One of the things that always bugs me about using Readers and Streams in

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.