Comments (9)
This example is oversimplified by the way. I also removed \\.\pipe\
from all names to make .StartsWith()
work.
from h.pipes.
In fact, I want to replace
var connectionPipeName = $"{PipeName}_{++NextPipeId}";
to
var connectionPipeName = $"{PipeName}_{Guid.NewGuid()}";
P.S. I released this change.
from h.pipes.
The library also contains PipeWatcher.GetActivePipes()
, which contains the following code:
public static IReadOnlyCollection<string> GetActivePipes()
{
return Directory
.EnumerateFiles(@"\\.\pipe\")
.Select(path => path.Replace(@"\\.\pipe\", string.Empty))
.ToList();
}
But I do not recommend using pipe file enumeration in principle, it is very slow.
from h.pipes.
Regarding the problem with invalid characters, yes, EnumerateFiles
returns such an exception when a path contains System.IO.Path.GetInvalidPathChars
:
T:System.ArgumentException:
// path is a zero-length string, contains only white space, or contains invalid
// characters. You can query for invalid characters by using the System.IO.Path.GetInvalidPathChars
// method. - or - searchPattern does not contain a valid pattern.
But as I said, EnumerateFiles
is generally not good for keeping track of pipes, it is very slow.
from h.pipes.
At the moment I'm trying to figure out why you need to monitor active pipes at all?
from h.pipes.
I don't need all the pipes but I just need to have what server uses currently. I see that during operation I can have:
pipename
pipename_1
pipename_2
, etc.
But if the client only knows pipename
, then client is unable to connect to the server when numbers are there. So, I had to find a pipe that starts with pipename
. To solve this, I enumerated all the pipes and pick a suitable one with the code above. However, in case there are multiple pipes at the same time, it takes only the first one and it might be an incorrect one.
from h.pipes.
Ok, the problem is clear. I will add a Connection.PipeName
property that will contain the currently used name.
The principle of the server is that there is a common pipe through which a unique pipeName is transmitted for each client, which is used for a direct connection with the client. Without this trick, only one client would be able to connect to the server. But, in fact, there is already a SingleConnectionPipeServer
class that is optimized for a single connection.
from h.pipes.
I have released a new version. I removed the Connection.Id
and Connection.Name
properties because the Connection.PipeName
will be unique.
from h.pipes.
That's a huge change. Thank you for quick reply. I'll try to use this one. And also will try SingleConnectionPipeServer
, which seems to be the best way for my use case.
from h.pipes.
Related Issues (20)
- Large messages on .NET 6 fail to send HOT 9
- PipeServer crashing with many connections, IOException: 'Pipe is broken' HOT 13
- SemaphoreFullException when CancellationToken is cancelled before semaphore is entered
- Feature request: Have a connection identifier on the server based on a client connection HOT 3
- Application getting terminated HOT 5
- The server stops working HOT 8
- Feature request: Support CreatePipeStreamFunc on the client as well
- Handles are not disposed HOT 1
- Implementation questions HOT 1
- Different Send and Receive Types Info Request HOT 1
- Compiler Errors: Tests, 4.8
- .NET 8 support HOT 2
- Does this library support read-only or write-only? HOT 11
- ConsoleApp sample server generates an exception with .NET 8.0 HOT 3
- Couldn't send data in specflow testing application via pipes
- Cannot access a disposed object. HOT 3
- I am getting below issue when i am communicating from .net framework app to .net 7 HOT 6
- MessagePack Unions not serialized correctly. HOT 2
- Security question(s) regarding BinaryFormatter HOT 6
- Explore possibility to use DataFlow Task Parallel library
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from h.pipes.