forked from zeromq/clrzmq4
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmdclient.cs
37 lines (35 loc) · 959 Bytes
/
mdclient.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
using System;
using System.Linq;
using System.Threading;
using ZeroMQ;
namespace Examples
{
using MDCliApi; // Let us build this source without creating a library
static partial class Program
{
// Majordomo Protocol client example
// Uses the mdcli API to hide all MDP aspects
public static void MDClient(string[] args)
{
CancellationTokenSource cts = new CancellationTokenSource();
Console.CancelKeyPress += (s, ea) =>
{
ea.Cancel = true;
cts.Cancel();
};
using (MajordomoClient session = new MajordomoClient("tcp://127.0.0.1:5555", Verbose))
{
int count;
for (count = 0; count < 100000; count++)
{
ZMessage request = new ZMessage();
request.Prepend(new ZFrame("Hello world"));
using (ZMessage reply = session.Send("echo", request, cts))
if (reply == null)
break; // Interrupt or failure
}
Console.WriteLine("{0} requests/replies processed\n", count);
}
}
}
}