Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/acdvorak/named-pipe-wrapper
Wrapper library for Windows Named Pipes in C# / .NET 4.0 / VS 2010
https://github.com/acdvorak/named-pipe-wrapper
Last synced: 2 months ago
JSON representation
Wrapper library for Windows Named Pipes in C# / .NET 4.0 / VS 2010
- Host: GitHub
- URL: https://github.com/acdvorak/named-pipe-wrapper
- Owner: acdvorak
- License: mit
- Created: 2013-09-16T13:40:44.000Z (over 11 years ago)
- Default Branch: master
- Last Pushed: 2023-07-31T21:51:08.000Z (over 1 year ago)
- Last Synced: 2024-11-14T12:56:33.094Z (2 months ago)
- Language: C#
- Homepage:
- Size: 6.11 MB
- Stars: 233
- Watchers: 19
- Forks: 178
- Open Issues: 35
-
Metadata Files:
- Readme: README.md
- License: LICENSE.txt
Awesome Lists containing this project
- my-awesome - named-pipe-wrapper - Wrapper library for Windows Named Pipes in C# / .NET 4.0 / VS 2010 (C#)
README
# Named Pipe Wrapper for .NET 4.0
A simple, easy to use, strongly-typed wrapper around .NET named pipes.
# NuGet Package
Available as a [NuGet package](https://www.nuget.org/packages/NamedPipeWrapper/).
# Features
* Create named pipe servers that can handle multiple client connections simultaneously.
* Send strongly-typed messages between clients and servers: any serializable .NET object can be sent over a pipe and will be automatically serialized/deserialized, including cyclical references and complex object graphs.
* Messages are sent and received asynchronously on a separate background thread and marshalled back to the calling thread (typically the UI).
* Supports large messages - up to 300 MiB.# Requirements
Requires .NET 4.0 full.
# Usage
Message:
_(Class must have a [`[Serializable]` attribute](https://learn.microsoft.com/en-us/dotnet/api/system.serializableattribute?redirectedfrom=MSDN&view=net-7.0))_
```csharp
[Serializable]
class SomeClass
{
public int Id;
public string Text;
}
```Server:
```csharp
var server = new NamedPipeServer("MyServerPipe");server.ClientConnected += delegate(NamedPipeConnection conn)
{
Console.WriteLine("Client {0} is now connected!", conn.Id);
conn.PushMessage(new SomeClass { Text: "Welcome!" });
};server.ClientMessage += delegate(NamedPipeConnection conn, SomeClass message)
{
Console.WriteLine("Client {0} says: {1}", conn.Id, message.Text);
};// Start up the server asynchronously and begin listening for connections.
// This method will return immediately while the server runs in a separate background thread.
server.Start();// ...
```Client:
```csharp
var client = new NamedPipeClient("MyServerPipe");client.ServerMessage += delegate(NamedPipeConnection conn, SomeClass message)
{
Console.WriteLine("Server says: {0}", message.Text);
};// Start up the client asynchronously and connect to the specified server pipe.
// This method will return immediately while the client runs in a separate background thread.
client.Start();// ...
```# MIT License
Named Pipe Wrapper for .NET is licensed under the [MIT license](LICENSE.txt).