Skip to content

IPC library utilizes named pipes to allow communication between different processes running on the same machine.

License

Notifications You must be signed in to change notification settings

snowberry-software/Snowberry.IPC

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

25 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

License NuGet Version

Snowberry.IPC

Interprocess communication (IPC) library utilizes named pipes to allow communication between different processes running on the same machine.

How to use it

Server

using var serverPipe = new ServerPipe("EXAMPLE_PIPE", "Example Server", CancellationToken.None)
{
    UseDynamicDataPacketSize = true
};

serverPipe.Initialize();

serverPipe.DataReceived += (s, e) =>
{
    Console.ForegroundColor = ConsoleColor.Green;
    Console.WriteLine("Client [Len = {0}]: {1}", e.Length, Encoding.UTF8.GetString(e.Data));
    Console.ResetColor();
};

serverPipe.GotConnectionEvent += (sender, e) =>
{
    Console.WriteLine("Server pipe got a new client...");
};

serverPipe.PipeClosed += (_, reason) =>
{
    Console.WriteLine("Server pipe got closed ({0})...", reason);
};

await serverPipe.WaitForClientAsync();

...

await serverPipe.WriteAsync(Encoding.UTF8.GetBytes("This is sent from the server!"));

Client

using var clientPipe = new ClientPipe(".", "EXAMPLE_PIPE", "Example Client")
{
    UseDynamicDataPacketSize = true
};

clientPipe.DataReceived += (s, e) =>
{
    Console.ForegroundColor = ConsoleColor.Green;
    Console.WriteLine("Server [Len = {0}]: {1}", e.Length, Encoding.UTF8.GetString(e.Data));
    Console.ResetColor();
};

clientPipe.PipeClosed += (_, reason) =>
{
    Console.WriteLine("Client pipe got closed ({0})...", reason);
};

await clientPipe.ConnectAsync();

clientPipe.StartReadingAsync(CancellationToken.None);

...

await clientPipe.WriteAsync(Encoding.UTF8.GetBytes("This is sent from the client!"));

About

IPC library utilizes named pipes to allow communication between different processes running on the same machine.

Topics

Resources

License

Stars

Watchers

Forks

Languages