Crossroads I/O bindings for .NET and Mono
OTHER License
This project aims to provide the full functionality of the underlying Crossroads I/O API to .NET projects.
Bundled libxs version: 1.0.1 (stable)
The quickest way to get started with crossroads-net is by using the NuGet package. The NuGet packages include a copy of the native libxs.dll, which is required to use crossroads-net.
You may also build crossroads-net directly from the source. See the Development Environment Setup instructions below for more detail.
To get an idea of how to use crossroads-net, have a look at the following example.
using System;
using System.Text;
using System.Threading;
using CrossroadsIO;
namespace ServerExample
{
class Program
{
static void Main(string[] args)
{
// Context, server socket
using (Context context = Context.Create())
using (Socket server = context.CreateSocket(SocketType.REP))
{
server.Bind("tcp://*:5555");
while (true)
{
// Wait for next request from client
string message = server.Receive(Encoding.Unicode);
Console.WriteLine("Received request: {0}", message);
// Do Some 'work'
Thread.Sleep(1000);
// Send reply back to client
server.Send("World", Encoding.Unicode);
}
}
}
}
}
using System;
using System.Text;
using CrossroadsIO;
namespace ClientExample
{
class Program
{
static void Main(string[] args)
{
// Context and client socket
using (Context context = Context.Create())
using (Socket client = context.CreateSocket(SocketType.REQ))
{
client.Connect("tcp://localhost:5555");
string request = "Hello";
for (int requestNum = 0; requestNum < 10; requestNum++)
{
Console.WriteLine("Sending request {0}...", requestNum);
client.Send(request, Encoding.Unicode);
string reply = client.Receive(Encoding.Unicode);
Console.WriteLine("Received reply {0}: {1}", requestNum, reply);
}
}
}
}
}
Crossroads I/O is a fork of ZeroMQ, so more C# examples can be found in the ZeroMQ Guide or in the examples repository. Tutorials and API documentation specific to crossroads-net are on the way.
On Windows/.NET, crossroads-net is developed with Visual Studio 2010. Mono development is done with MonoDevelop 2.8+.
crossroads-net depends on libxs.dll
, which will be retrieved automatically via NuGet. If you require a specific version of libxs, you can compile it from the libxs sources.
build.cmd
to build the project and run the test suite./build
.If you want to use a custom build of libxs.dll
, perform the following steps:
src/Core/packages.config
file. This will prevent the NuGet package from being retrieved.src/packages/libxs-*
that may have been downloaded previously.libxs.dll
to lib/x86
and lib/x64
, respectively.Note that PGM-related tests will fail if a non-PGM build of libxs is used.
NOTE: Mono 2.10.7+ is required for development only, as the NuGet scripts and executables require this version to be present. If you choose to install dependencies manually, you may use any version of Mono 2.6+.
NuGet relies on several certificates to be registered with Mono. The following is an example terminal session (on Ubuntu) for setting this up correctly. This assumes you have already installed Mono 2.10.7 or higher.
$ mozroots --import --sync
$ certmgr -ssl https://go.microsoft.com
$ certmgr -ssl https://nugetgallery.blob.core.windows.net
$ certmgr -ssl https://nuget.org
This should result in a working Mono setup for use with NuGet.
Either clone the libxs repository or download the sources, and then follow the build/install instructions for your platform.
Use the --with-pgm
option if possible.
nuget.sh
, which downloads any dependent packages (e.g., Machine.Specifications for acceptance tests).make
to build the project./build
.NOTE: The combination of P/Invoke, MSpec, and Mono currently has issues, so the test suite does not automatically run.
NOTE: crossroads-net
only supports x86 builds on Mono at this time
Issues should be logged on the GitHub issue tracker for this project.
When reporting issues, please include the following information if possible:
Pull requests and patches are always appreciated! To speed up the merge process, please follow the guidelines below when making a pull request:
Pull requests will still be accepted if some of these guidelines are not followed: changes will just take longer to merge, as the missing pieces will need to be filled in.
This project is released under the LGPL license, as is the native libxs library. See LICENSE for more details as well as the Crossroads I/O Licensing page.