Skip to content

Commit

Permalink
Updating C# Examples
Browse files Browse the repository at this point in the history
  • Loading branch information
metadings committed Feb 1, 2015
1 parent 08c9ecf commit 211e494
Show file tree
Hide file tree
Showing 46 changed files with 131 additions and 131 deletions.
10 changes: 5 additions & 5 deletions examples/C#/asyncsrv.cs
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ static void AsyncSrv_Client(ZContext context, int i)
// It collects responses as they arrive, and it prints them out. We will
// run several client tasks in parallel, each with a different random ID.

using (var client = ZSocket.Create(context, ZSocketType.DEALER))
using (var client = new ZSocket(context, ZSocketType.DEALER))
{
// Set identity to make tracing easier
client.Identity = Encoding.UTF8.GetBytes("CLIENT" + i);
Expand Down Expand Up @@ -85,8 +85,8 @@ static void AsyncSrv_ServerTask(ZContext context)
// one request at a time but one client can talk to multiple workers at
// once.

using (var frontend = ZSocket.Create(context, ZSocketType.ROUTER))
using (var backend = ZSocket.Create(context, ZSocketType.DEALER))
using (var frontend = new ZSocket(context, ZSocketType.ROUTER))
using (var backend = new ZSocket(context, ZSocketType.DEALER))
{
// Frontend socket talks to clients over TCP
frontend.Bind("tcp://*:5570");
Expand Down Expand Up @@ -115,7 +115,7 @@ static void AsyncSrv_ServerWorker(ZContext context, int i)
// Each worker task works on one request at a time and sends a random number
// of replies back, with random delays between replies:

using (var worker = ZSocket.Create(context, ZSocketType.DEALER))
using (var worker = new ZSocket(context, ZSocketType.DEALER))
{
worker.Connect("inproc://backend");

Expand Down Expand Up @@ -167,7 +167,7 @@ public static void AsyncSrv(IDictionary<string, string> dict, string[] args)
// The main thread simply starts several clients and a server, and then
// waits for the server to finish.

using (var context = ZContext.Create())
using (var context = new ZContext())
{
for (int i = 0; i < 5; ++i)
{
Expand Down
4 changes: 2 additions & 2 deletions examples/C#/eagain.cs
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,8 @@ public static void EAgain(IDictionary<string, string> dict, string[] args)
// Author: metadings
//

using (var context = ZContext.Create())
using (var mailbox = ZSocket.Create(context, ZSocketType.DEALER))
using (var context = new ZContext())
using (var mailbox = new ZSocket(context, ZSocketType.DEALER))
{
mailbox.SendHighWatermark = 4;
mailbox.SendTimeout = TimeSpan.Zero;
Expand Down
4 changes: 2 additions & 2 deletions examples/C#/flclient1.cs
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ public static void FLClient1(IDictionary<string, string> dict, string[] args)
// to. If it has two or more servers to talk to, it will try each server just
// once:

using (var context = ZContext.Create())
using (var context = new ZContext())
using (var request = new ZFrame("Hello World"))
{
ZFrame reply = null;
Expand Down Expand Up @@ -83,7 +83,7 @@ static ZFrame FLClient1_TryRequest(ZContext context, string endpoint, ZFrame req
{
Console.WriteLine("I: trying echo service at {0}...", endpoint);

using (var client = ZSocket.Create(context, ZSocketType.REQ))
using (var client = new ZSocket(context, ZSocketType.REQ))
{
client.Connect(endpoint);

Expand Down
4 changes: 2 additions & 2 deletions examples/C#/flclient2.cs
Original file line number Diff line number Diff line change
Expand Up @@ -44,8 +44,8 @@ public FLClient()
{
// Constructor

context = ZContext.Create();
socket = ZSocket.Create(context, ZSocketType.DEALER);
context = new ZContext();
socket = new ZSocket(context, ZSocketType.DEALER);
socket.Linger = GLOBAL_TIMEOUT;
}

Expand Down
4 changes: 2 additions & 2 deletions examples/C#/flserver1.cs
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,8 @@ public static void FLServer1(IDictionary<string, string> dict, string[] args)
args = new string[] { "tcp://127.0.0.1:7780" };
}

using (var context = ZContext.Create())
using (var server = ZSocket.Create(context, ZSocketType.REP))
using (var context = new ZContext())
using (var server = new ZSocket(context, ZSocketType.REP))
{
server.Bind(args[0]);

Expand Down
4 changes: 2 additions & 2 deletions examples/C#/flserver2.cs
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,8 @@ public static void FLServer2(IDictionary<string, string> dict, string[] args)

string endpoint = args[0];

using (var context = ZContext.Create())
using (var server = ZSocket.Create(context, ZSocketType.REP))
using (var context = new ZContext())
using (var server = new ZSocket(context, ZSocketType.REP))
{
server.Bind(endpoint);
Console.WriteLine("I: server is ready as {0}", endpoint);
Expand Down
4 changes: 2 additions & 2 deletions examples/C#/flserver3.cs
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,8 @@ public static void FLServer3(IDictionary<string, string> dict, string[] args)
string bind_endpoint = "tcp://*:5555";
string connect_endpoint = "tcp://127.0.0.1:5555";

using (var context = ZContext.Create())
using (var server = ZSocket.Create(context, ZSocketType.ROUTER))
using (var context = new ZContext())
using (var server = new ZSocket(context, ZSocketType.ROUTER))
{
Console.CancelKeyPress += (s, ea) =>
{
Expand Down
4 changes: 2 additions & 2 deletions examples/C#/hwclient.cs
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,8 @@ public static void HWClient(IDictionary<string, string> dict, string[] args)
//

// Create
using (var context = ZContext.Create())
using (var requester = ZSocket.Create(context, ZSocketType.REQ))
using (var context = new ZContext())
using (var requester = new ZSocket(context, ZSocketType.REQ))
{
// Connect
requester.Connect("tcp://127.0.0.1:5555");
Expand Down
4 changes: 2 additions & 2 deletions examples/C#/hwserver.cs
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,8 @@ public static void HWServer(IDictionary<string, string> dict, string[] args)
string name = args[0];

// Create
using (var context = ZContext.Create())
using (var responder = ZSocket.Create(context, ZSocketType.REP))
using (var context = new ZContext())
using (var responder = new ZSocket(context, ZSocketType.REP))
{
// Bind
responder.Bind("tcp://*:5555");
Expand Down
8 changes: 4 additions & 4 deletions examples/C#/identity.cs
Original file line number Diff line number Diff line change
Expand Up @@ -18,13 +18,13 @@ public static void Identity(IDictionary<string, string> dict, string[] args)
// Author: metadings
//

using (var context = ZContext.Create())
using (var sink = ZSocket.Create(context, ZSocketType.ROUTER))
using (var context = new ZContext())
using (var sink = new ZSocket(context, ZSocketType.ROUTER))
{
sink.Bind("inproc://example");

// First allow 0MQ to set the identity
using (var anonymous = ZSocket.Create(context, ZSocketType.REQ))
using (var anonymous = new ZSocket(context, ZSocketType.REQ))
{
anonymous.Connect("inproc://example");
anonymous.Send(new ZFrame("ROUTER uses REQ's generated UUID"));
Expand All @@ -35,7 +35,7 @@ public static void Identity(IDictionary<string, string> dict, string[] args)
}

// Then set the identity ourselves
using (var identified = ZSocket.Create(context, ZSocketType.REQ))
using (var identified = new ZSocket(context, ZSocketType.REQ))
{
identified.IdentityString = "PEER2";
identified.Connect("inproc://example");
Expand Down
4 changes: 2 additions & 2 deletions examples/C#/interrupt.cs
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,8 @@ public static void Interrupt(IDictionary<string, string> dict, string[] args)

string name = args[0];

using (var context = ZContext.Create())
using (var responder = ZSocket.Create(context, ZSocketType.REP))
using (var context = new ZContext())
using (var responder = new ZSocket(context, ZSocketType.REP))
{
Console.CancelKeyPress += (s, ea) =>
{
Expand Down
10 changes: 5 additions & 5 deletions examples/C#/lbbroker.cs
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ static partial class Program
static void LBBroker_Client(ZContext context, int i)
{
// Create a socket
using (var client = ZSocket.Create(context, ZSocketType.REQ))
using (var client = new ZSocket(context, ZSocketType.REQ))
{
// Set a printable identity
client.IdentityString = "CLIENT" + i;
Expand Down Expand Up @@ -58,7 +58,7 @@ static void LBBroker_Worker(ZContext context, int i)
// This is the worker task, using a REQ socket to do load-balancing.

// Create socket
using (var worker = ZSocket.Create(context, ZSocketType.REQ))
using (var worker = new ZSocket(context, ZSocketType.REQ))
{
// Set a printable identity
worker.IdentityString = "WORKER" + i;
Expand Down Expand Up @@ -118,9 +118,9 @@ public static void LBBroker(IDictionary<string, string> dict, string[] args)
// just a queue of next available workers.

// Prepare our context and sockets
using (var context = ZContext.Create())
using (var frontend = ZSocket.Create(context, ZSocketType.ROUTER))
using (var backend = ZSocket.Create(context, ZSocketType.ROUTER))
using (var context = new ZContext())
using (var frontend = new ZSocket(context, ZSocketType.ROUTER))
using (var backend = new ZSocket(context, ZSocketType.ROUTER))
{
// Bind
frontend.Bind("inproc://frontend");
Expand Down
4 changes: 2 additions & 2 deletions examples/C#/lpclient.cs
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ static ZSocket LPClient_CreateZSocket(ZContext context, string name, out ZError
// Helper function that returns a new configured socket
// connected to the Lazy Pirate queue

var requester = ZSocket.Create(context, ZSocketType.REQ);
var requester = new ZSocket(context, ZSocketType.REQ);
requester.IdentityString = name;

if (!requester.Connect("tcp://127.0.0.1:5555", out error))
Expand All @@ -53,7 +53,7 @@ public static void LPClient(IDictionary<string, string> dict, string[] args)
ZSocket requester = null;
try { // using (requester)

using (var context = ZContext.Create())
using (var context = new ZContext())
{
ZError error;

Expand Down
4 changes: 2 additions & 2 deletions examples/C#/lpserver.cs
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,8 @@ static partial class Program

public static void LPServer(IDictionary<string, string> dict, string[] args)
{
using (var context = ZContext.Create())
using (var responder = ZSocket.Create(context, ZSocketType.REP))
using (var context = new ZContext())
using (var responder = new ZSocket(context, ZSocketType.REP))
{
responder.Bind("tcp://*:5555");

Expand Down
6 changes: 3 additions & 3 deletions examples/C#/lvcache.cs
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,9 @@ public static void LVCache(IDictionary<string, string> dict, string[] args)
// Author: metadings
//

using (var context = ZContext.Create())
using (var frontend = ZSocket.Create(context, ZSocketType.SUB))
using (var backend = ZSocket.Create(context, ZSocketType.XPUB))
using (var context = new ZContext())
using (var frontend = new ZSocket(context, ZSocketType.SUB))
using (var backend = new ZSocket(context, ZSocketType.XPUB))
{
// Subscribe to every single topic from publisher
frontend.Bind("tcp://*:5557");
Expand Down
6 changes: 3 additions & 3 deletions examples/C#/msgqueue.cs
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,9 @@ public static void MsgQueue(IDictionary<string, string> dict, string[] args)

// Socket facing clients and
// Socket facing services
using (var context = ZContext.Create())
using (var frontend = ZSocket.Create(context, ZSocketType.ROUTER))
using (var backend = ZSocket.Create(context, ZSocketType.DEALER))
using (var context = new ZContext())
using (var frontend = new ZSocket(context, ZSocketType.ROUTER))
using (var backend = new ZSocket(context, ZSocketType.DEALER))
{
frontend.Bind("tcp://*:5559");
backend.Bind("tcp://*:5560");
Expand Down
6 changes: 3 additions & 3 deletions examples/C#/mspoller.cs
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,9 @@ public static void MSPoller(IDictionary<string, string> dict, string[] args)
// Author: metadings
//

using (var context = ZContext.Create())
using (var receiver = ZSocket.Create(context, ZSocketType.PULL))
using (var subscriber = ZSocket.Create(context, ZSocketType.SUB))
using (var context = new ZContext())
using (var receiver = new ZSocket(context, ZSocketType.PULL))
using (var subscriber = new ZSocket(context, ZSocketType.SUB))
{
// Connect to task ventilator
receiver.Connect("tcp://127.0.0.1:5557");
Expand Down
6 changes: 3 additions & 3 deletions examples/C#/msreader.cs
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,9 @@ public static void MSReader(IDictionary<string, string> dict, string[] args)
// Author: metadings
//

using (var context = ZContext.Create())
using (var receiver = ZSocket.Create(context, ZSocketType.PULL))
using (var subscriber = ZSocket.Create(context, ZSocketType.SUB))
using (var context = new ZContext())
using (var receiver = new ZSocket(context, ZSocketType.PULL))
using (var subscriber = new ZSocket(context, ZSocketType.SUB))
{
// Connect to task ventilator
receiver.Connect("tcp://127.0.0.1:5557");
Expand Down
10 changes: 5 additions & 5 deletions examples/C#/mtrelay.cs
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,8 @@ public static void MTRelay(IDictionary<string, string> dict, string[] args)
//

// Bind inproc socket before starting step2
using (var context = ZContext.Create())
using (var receiver = ZSocket.Create(context, ZSocketType.PAIR))
using (var context = new ZContext())
using (var receiver = new ZSocket(context, ZSocketType.PAIR))
{
receiver.Bind("inproc://step3");

Expand All @@ -37,7 +37,7 @@ public static void MTRelay(IDictionary<string, string> dict, string[] args)
static void MTRelay_step2(ZContext context)
{
// Bind inproc socket before starting step1
using (var receiver = ZSocket.Create(context, ZSocketType.PAIR))
using (var receiver = new ZSocket(context, ZSocketType.PAIR))
{
receiver.Bind("inproc://step2");

Expand All @@ -49,7 +49,7 @@ static void MTRelay_step2(ZContext context)
}

// Connect to step3 and tell it we're ready
using (var xmitter = ZSocket.Create(context, ZSocketType.PAIR))
using (var xmitter = new ZSocket(context, ZSocketType.PAIR))
{
xmitter.Connect("inproc://step3");

Expand All @@ -61,7 +61,7 @@ static void MTRelay_step2(ZContext context)
static void MTRelay_step1(ZContext context)
{
// Connect to step2 and tell it we're ready
using (var xmitter = ZSocket.Create(context, ZSocketType.PAIR))
using (var xmitter = new ZSocket(context, ZSocketType.PAIR))
{
xmitter.Connect("inproc://step2");

Expand Down
8 changes: 4 additions & 4 deletions examples/C#/mtserver.cs
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,9 @@ public static void MTServer(IDictionary<string, string> dict, string[] args)

// Socket to talk to clients and
// Socket to talk to workers
using (var context = ZContext.Create())
using (var clients = ZSocket.Create(context, ZSocketType.ROUTER))
using (var workers = ZSocket.Create(context, ZSocketType.DEALER))
using (var context = new ZContext())
using (var clients = new ZSocket(context, ZSocketType.ROUTER))
using (var workers = new ZSocket(context, ZSocketType.DEALER))
{
clients.Bind("tcp://*:5555");
workers.Bind("inproc://workers");
Expand All @@ -42,7 +42,7 @@ public static void MTServer(IDictionary<string, string> dict, string[] args)
static void MTServer_Worker(ZContext context)
{
// Socket to talk to dispatcher
using (var server = ZSocket.Create(context, ZSocketType.REP))
using (var server = new ZSocket(context, ZSocketType.REP))
{
server.Connect("inproc://workers");

Expand Down
4 changes: 2 additions & 2 deletions examples/C#/pathopub.cs
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,8 @@ public static void PathoPub(IDictionary<string, string> dict, string[] args)
args = new string[] { null };
}

using (var context = ZContext.Create())
using (var publisher = ZSocket.Create(context, ZSocketType.PUB))
using (var context = new ZContext())
using (var publisher = new ZSocket(context, ZSocketType.PUB))
{
if (args[0] != null)
{
Expand Down
4 changes: 2 additions & 2 deletions examples/C#/pathosub.cs
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,8 @@ public static void PathoSub(IDictionary<string, string> dict, string[] args)
args = new string[] { "tcp://127.0.0.1:5556" };
}

using (var context = ZContext.Create())
using (var subscriber = ZSocket.Create(context, ZSocketType.SUB))
using (var context = new ZContext())
using (var subscriber = new ZSocket(context, ZSocketType.SUB))
{
subscriber.Connect(args[0]);

Expand Down
6 changes: 3 additions & 3 deletions examples/C#/peering1.cs
Original file line number Diff line number Diff line change
Expand Up @@ -33,9 +33,9 @@ public static void Peering1(IDictionary<string, string> dict, string[] args)
string self = args[0];
Console.WriteLine("I: preparing broker as {0}", self);

using (var context = ZContext.Create())
using (var backend = ZSocket.Create(context, ZSocketType.PUB))
using (var frontend = ZSocket.Create(context, ZSocketType.SUB))
using (var context = new ZContext())
using (var backend = new ZSocket(context, ZSocketType.PUB))
using (var frontend = new ZSocket(context, ZSocketType.SUB))
{
// Bind backend to endpoint
backend.Bind("tcp://127.0.0.1:" + Peering1_GetPort(self));
Expand Down
Loading

0 comments on commit 211e494

Please sign in to comment.