Library Mode allows you to spawn an Agnos server process and connect to it directly, instead of having to set up a separate server, publish its TCP port, and manage its life-cycle. The procedure that Agnos employs is very simple:
The library mode was a fundamental requirement from Agnos. When we started Agnos, our first and foremost purpose was to allow clients (written in different languages) to utilize our libraries, and we wanted the process to be as smooth as possible. This is why Agnos supports this seemingly trivial-to-implement feature internally.
Initially, we sought to implement library mode over pipes or Unix-domain sockets, for greater efficiency. However, being a cross-platform library meant we had to resort to using this scheme (of regular TCP sockets) on some platforms, and besides, it turned out that Unix-domain sockets are not faster than localhost -bound sockets, since the network stack has been heavily optimized for this case (both on Linux and Windows). So all in all, the marginal performance gain was not worth the effort.
To create a library mode connection, you can use the ConnectProc factory-method of the Client class. The function goes by different names in different languages (see more here). It takes the filename of the process to spawn, and optionally custom command-line arguments.
MyService.Client client = MyService.MyClient.ConnectProc(@"c:\path\to\myserver.exe");
In our products, we provide an Initialize factory method that locates the server’s path automatically. This way, all the end user has to do is:
MyService.Client client = MyService.Initialize();