Skip to content

High performance and lightweight RPC library for .Net Framework and .Net Portable

Notifications You must be signed in to change notification settings

NaxAlpha/LibRPC

Repository files navigation

LibRPC

Join the chat at https://gitter.im/NaxAlpha/LibRPC Continuous Build at https://ci.appveyor.com/project/NaxAlpha/librpc/ Download Nuget package at https://www.nuget.org/packages/LibRPC/

LibRPC is very lightweight, realtime and high performance library for both .Net Framework and .Net Portable. It provides stream based RPC Framework whick makes it very light and extensible. It basically works on server/client and request/respond architucture. Checkout Examples for basic usage

Example

LibRPC uses stream based communication so you can use it in TCP, Pipes and any other stream based protocol. Following is basic server-client example where we simple call server to add two numbers Imports LibRPC.Basic:

Basic Server (VB.Net)

	Private Sub Server()
		Dim tcp As New TcpListener(IPAddress.Loopback, 11221)
		tcp.Start()
		While True
			Dim sock = tcp.AcceptTcpClient()
			Dim host = New RPCHost(sock.GetStream())
			host.On(6644, New Func(Of Integer, Integer, Integer)(AddressOf OnAdd))
		End While
	End Sub

	Private Function OnAdd(x As Integer, y As Integer) As Integer
		Return x + y
	End Function

Basic Client (VB.Net)

	Private Sub Client()
		Dim tcp As New TcpClient("localhost", 11221)
		Dim host As New RPCHost(tcp.GetStream())
		Console.WriteLine(host.Call(Of Integer)(6644, 5, 9)) '14
	End Sub

Following is C# using LibRPC.Basic;:

Basic Server (C#.Net)

	private void Server()
	{
		TcpListener tcp = new TcpListener(IPAddress.Loopback, 11221);
		tcp.Start();
		while (true) {
			dynamic sock = tcp.AcceptTcpClient();
			dynamic host = new RPCHost(sock.GetStream());
			host.On(6644, new Func<int, int, int>(OnAdd));
		}
	}

	private int OnAdd(int x, int y)
	{
		return x + y;
	}

Basic Client (C#.Net)

	private void Client()
	{
		TcpClient tcp = new TcpClient("localhost", 11221);
		RPCHost host = new RPCHost(tcp.GetStream());
		Console.WriteLine(host.Call<int>(6644, 5, 9)); //14
	}

About

High performance and lightweight RPC library for .Net Framework and .Net Portable

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published