Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
tree: 4fdecddfd1
Fetching contributors…

Cannot retrieve contributors at this time

47 lines (37 sloc) 1.227 kb
//
// Shows how to handle Ctrl-C
//
// Author: Tomas Roos
// Email: ptomasroos@gmail.com
using System;
using System.Text;
using System.Threading;
using ZMQ;
namespace ZMQGuide
{
internal class Program
{
public static void Main(string[] args)
{
using (var context = new Context(1))
{
using (Socket replyer = context.Socket(SocketType.REP))
{
replyer.Bind("tcp://*:5555");
bool interrupted = false;
Console.CancelKeyPress += delegate { interrupted = true; };
const string replyMessage = "World";
while (!interrupted)
{
string message = replyer.Recv(Encoding.Unicode);
Console.WriteLine("Received request: {0}", message);
// Simulate work, by sleeping
Thread.Sleep(1000);
// Send reply back to client
replyer.Send(replyMessage, Encoding.Unicode);
}
}
}
}
}
}
Jump to Line
Something went wrong with that request. Please try again.