dhavleak

dhavleak
- Name: [not set]
- Favorite Languages: [not set]
- Website: [not set]
- Location: [not set]
- About Me: [not set]
-
Interprocess Communication using Named Pipes in C#
02/15/2009 - 05:37
Brandon - thanks for the excellent tutorial and code sample. Even with the .Net 3.5 support for named pipes this is still very useful considering 3.5's current lack of ubiquity.
One question. A very minor point: When we're listening for clients to connect, would it make sense to 'continue' instead of 'break' when a client connection fails. i.e. in the snippet below, would it make more sense to replace break with continue? My thinking is, just because one client failed to connect, doesn't mean that others will fail as well, so perhaps we should go back into the while loop to listen for the next client. Having said that, I don't know what would cause a client to fail to connect, and I certainly can't simulate such a failure to test the theory, so this really becomes a corner case that will rarely be exercised.
private void Listen()
{
while (true)
{
//CreateNamedPipe, etc.
int success = ConnectNamedPipe(
clientPipeHandle,
IntPtr.Zero);
//failed to connect client pipe
if (success != 1)
break; // should we replace this with continue?
}
}
Recent Comments