LibRPC
1.0.0
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
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
:
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
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;
:
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;
}
private void Client()
{
TcpClient tcp = new TcpClient("localhost", 11221);
RPCHost host = new RPCHost(tcp.GetStream());
Console.WriteLine(host.Call<int>(6644, 5, 9)); //14
}