Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Newer
Older
100644 48 lines (44 sloc) 1.027 kb
b3318a9 @metadings Updating C# Examples
metadings authored
1 using System;
2 using System.Collections.Generic;
3 using System.Linq;
4 using System.Text;
5 using System.Threading;
6
7 using ZeroMQ;
8
00b6290 @metadings Updating C# Examples
metadings authored
9 namespace Examples
b3318a9 @metadings Updating C# Examples
metadings authored
10 {
11 static partial class Program
12 {
1a634ca @metadings Updating C# Examples
metadings authored
13 public static void PSEnvPub(string[] args)
b3318a9 @metadings Updating C# Examples
metadings authored
14 {
3d864eb @metadings Updating C# Examples
metadings authored
15 //
16 // Pubsub envelope publisher
17 //
c558db7 @metadings Updating C# Examples
metadings authored
18 // Author: metadings
3d864eb @metadings Updating C# Examples
metadings authored
19 //
20
21 // Prepare our context and publisher
211e494 @metadings Updating C# Examples
metadings authored
22 using (var context = new ZContext())
23 using (var publisher = new ZSocket(context, ZSocketType.PUB))
aef1dd9 @metadings Updating C# Examples
metadings authored
24 {
ea8de92 @metadings Updating C# Examples
metadings authored
25 publisher.Linger = TimeSpan.Zero;
b3318a9 @metadings Updating C# Examples
metadings authored
26 publisher.Bind("tcp://*:5563");
27
aef1dd9 @metadings Updating C# Examples
metadings authored
28 while (true)
29 {
3d864eb @metadings Updating C# Examples
metadings authored
30 // Write two messages, each with an envelope and content
aef1dd9 @metadings Updating C# Examples
metadings authored
31 using (var message = new ZMessage())
32 {
86c9ec2 @metadings Updating C# Examples
metadings authored
33 message.Add(new ZFrame("A"));
34 message.Add(new ZFrame("We don't want to see this"));
11e05df @metadings Updating C# Examples
metadings authored
35 publisher.Send(message);
b3318a9 @metadings Updating C# Examples
metadings authored
36 }
aef1dd9 @metadings Updating C# Examples
metadings authored
37 using (var message = new ZMessage())
38 {
86c9ec2 @metadings Updating C# Examples
metadings authored
39 message.Add(new ZFrame("B"));
40 message.Add(new ZFrame("We would like to see this"));
11e05df @metadings Updating C# Examples
metadings authored
41 publisher.Send(message);
b3318a9 @metadings Updating C# Examples
metadings authored
42 }
ea8de92 @metadings Updating C# Examples
metadings authored
43 Thread.Sleep(1000);
b3318a9 @metadings Updating C# Examples
metadings authored
44 }
45 }
46 }
47 }
48 }
Something went wrong with that request. Please try again.