本文整理汇总了C#中ZmqSocket.Bind方法的典型用法代码示例。如果您正苦于以下问题:C# ZmqSocket.Bind方法的具体用法?C# ZmqSocket.Bind怎么用?C# ZmqSocket.Bind使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ZmqSocket
的用法示例。
在下文中一共展示了ZmqSocket.Bind方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: InitialiseSocket
public void InitialiseSocket()
{
m_PublishSocket = m_Context.CreateSocket(SocketType.PUB);
m_PublishSocket.Bind("epgm://239.1.1.1:9500");
m_PublishSocket.Bind("tcp://*:9500");
m_PublishSocket.Bind("inproc://Local");
}
示例2: Open
private static void Open(Object cancelationToken)
{
context = ZmqContext.Create();
frontend = context.CreateSocket(SocketType.ROUTER);
backend = context.CreateSocket(SocketType.DEALER);
backend.Identity = Encoding.UTF8.GetBytes("inproc://workers");
frontend.Bind("tcp://127.0.0.1:5000");
backend.Bind("inproc://workers");
workerThreads = new Thread[2];
for (int threadId = 0; threadId < workerThreads.Length; threadId++)
{
workerThreads[threadId] = new Thread(WorkerRoutine);
workerThreads[threadId].Start(context);
}
frontend.ReceiveReady += new EventHandler<SocketEventArgs>(frontend_ReceiveReady);
backend.ReceiveReady += new EventHandler<SocketEventArgs>(backend_ReceiveReady);
Poller poller = new Poller(new[] { frontend, backend });
var token = (CancellationToken)cancelationToken;
while (!token.IsCancellationRequested)
{
poller.Poll(TimeSpan.FromMilliseconds(100));
}
}
示例3: ZmqPublisher
public ZmqPublisher(string endpoint)
{
_endpoint = endpoint;
_context = ZmqContext.Create();
_socket = _context.CreateSocket(SocketType.PUB);
_socket.Bind(_endpoint);
}
示例4: CreateCommandReceiverSocket
public void CreateCommandReceiverSocket(string endpoint)
{
_receptionSocket = _context.CreateSocket(SocketType.PULL);
_receptionSocket.Linger = TimeSpan.FromSeconds(1);
_receptionSocket.ReceiveHighWatermark = 30000;
_receptionSocket.Bind(endpoint);
_logger.DebugFormat("Command processor socket bound to {0}", endpoint);
}
示例5: ZeroMqMessagePublisher
public ZeroMqMessagePublisher(ZmqContext context)
{
Console.WriteLine("Hey there");
_pub = context.CreateSocket(SocketType.PUB);
_pub.Bind("tcp://*:5555");
Console.WriteLine("Hello");
}
示例6: CreateReceiveSocket
public void CreateReceiveSocket()
{
m_SubscribeSocket = m_Context.CreateSocket(SocketType.SUB);
m_SubscribeSocket.SubscribeAll();
m_SubscribeSocket.Connect("epgm://239.1.1.1:9500");
m_SubscribeSocket.Bind("tcp://*:9501");
m_SubscribeSocket.Connect("inproc://Local");
}
示例7: Bind
public override void Bind(ZmqSocket socket, ZeroRoute config)
{
ZeroLog.LogInfo("pull bind....");
foreach (var endPoint in config.ConnectEndPoints())
{
socket.Bind(endPoint);
ZeroLog.LogInfo("pull bind....");
}
}
示例8: Start
public void Start()
{
_context = ZmqContext.Create();
_commandReceiver = _context.CreateSocket(SocketType.REP);
_commandReceiver.Bind("tcp://*:7777");
_dequeueReceiver = _context.CreateSocket(SocketType.PUB);
_dequeueReceiver.Bind("tcp://*:7778");
StartListener();
}
示例9: Start
public void Start()
{
if (!string.IsNullOrWhiteSpace(_PubEndPoint))
{
ZmqEventPublisher = ZeroMessageQueue.ZmqContext.CreateSocket(SocketType.PUB);
ZmqEventPublisher.Bind(_PubEndPoint);
using (var messageStore = IoCFactory.Resolve<IMessageStore>())
{
messageStore.GetAllUnPublishedEvents()
.ForEach(eventContext => MessageQueue.Add(eventContext));
}
_WorkTask = Task.Factory.StartNew(PublishEvent, TaskCreationOptions.LongRunning);
}
}
示例10: Bind
public ZmqEndPoint Bind()
{
_socket = CreateSocket();
_endPoint = new ZmqEndPoint(_originalEndpoint.Value);
if (_endPoint.HasRandomPort)
_endPoint.SelectRandomPort(_peerId, _environment);
_socket.Bind(_endPoint.Value);
var endPointWithIp = new ZmqEndPoint(_socket.LastEndpoint);
_logger.InfoFormat("Socket bound, Inbound EndPoint: {0}", endPointWithIp.Value);
return endPointWithIp;
}
示例11: Main
static void Main(string[] args)
{
context_ = ZmqContext.Create();
socket_ = context_.CreateSocket(SocketType.PUB);
socket_.Bind("tcp://127.0.0.1:5000");
bool publish = true;
Task.Run(() => {
while (publish)
{
string timestring = DateTime.Now.ToString("u");
Console.WriteLine("Sending '{0}' to subscribers", timestring);
socket_.Send(timestring, Encoding.Unicode);
Thread.Sleep(1000);
}
});
Console.ReadLine();
publish = false;
}
示例12: Publisher
public Publisher(string _guid, string _host, int _port, ZmqContext _ctx)
{
guid = _guid;
host = _host;
port = _port;
if (_ctx == null)
ctx = ZmqContext.Create();
else
ctx = _ctx;
socket = ctx.CreateSocket(SocketType.PUB);
var bindString = String.Empty;
if(port > 0)
bindString = String.Format("tcp://*:{0}", port);
else
bindString = String.Format("inproc://{0}", guid.ToLower());
socket.Bind(bindString);
log.InfoFormat("Publisher successfuly binded on {0}", bindString);
socket.SendHighWatermark = 1000000;
socket.SendBufferSize = 128 * 1024;
}
示例13: ServerThread
void ServerThread()
{
using (context ?? (context = ZmqContext.Create()))
using (subscribeSocket = context.CreateSocket(SocketType.XSUB))
using (publishSocket = context.CreateSocket(SocketType.XPUB))
{
publishSocket.Bind(PublishAddress);
subscribeSocket.Bind(SubscribeAddress);
publishSocket.ReceiveReady += publishSocket_ReceiveReady;
subscribeSocket.ReceiveReady += subscribeSocket_ReceiveReady;
var poller = new Poller(new List<ZmqSocket> { subscribeSocket, publishSocket });
InitializationDone.Set();
while (true)
{
poller.Poll();
}
}
}
示例14: Start
public void Start(ZmqContext context)
{
this.SetUpMonitorChannel(context);
this.SetUpAddSubscriberCountChannel(context);
////this should work but the forwarder device appears to be broken - it does not use XSUb and XPUB sockets
////ForwarderDevice = new ForwarderDevice(context, PublishAddressServer, SubscribeAddressServer, DeviceMode.Threaded);
////ForwarderDevice.Start();
////while (!ForwarderDevice.IsRunning)
////{ }
QueueDevce = new QueueDevice(context, PubSubControlBackAddressServer, PubSubControlFrontAddress, DeviceMode.Threaded);
QueueDevce.Start();
while (!QueueDevce.IsRunning)
{
}
this.Writeline("Control channel started");
//this.Context = context;
this.cancellationTokenSource = new CancellationTokenSource();
var token = this.cancellationTokenSource.Token;
Task.Run(() =>
{
using (frontend = context.CreateSocket(SocketType.XSUB))
{
using (backend = context.CreateSocket(SocketType.XPUB))
{
frontend.Bind(Pipe.PublishAddressServer); ////"tcp://*:5550");
backend.Bind(Pipe.SubscribeAddressServer); ////"tcp://*:5553");
frontend.ReceiveReady += new EventHandler<SocketEventArgs>(FrontendReceiveReady);
backend.ReceiveReady += new EventHandler<SocketEventArgs>(BackendReceiveReady);
this.AddSubscriberCountChannel.ReceiveReady += new EventHandler<SocketEventArgs>(AddSubscriberCountChannelReceiveReady);
using (poller = new Poller(new ZmqSocket[] { frontend, backend, this.AddSubscriberCountChannel }))
{
Writeline("About to start polling");
while (true)
{
poller.Poll(new TimeSpan(0,0,0,0,5));
Writeline("polling");
if (token.IsCancellationRequested)
{
Writeline("break");
break;
}
}
}
Writeline("stopped polling and exiting");
}
}
},
token);
}
示例15: StartServer
/// <summary>
/// Start the server.
/// </summary>
public void StartServer()
{
//check that it's not already running
if (ServerRunning) return;
_context = ZmqContext.Create();
_routerSocket = _context.CreateSocket(SocketType.ROUTER);
_routerSocket.Bind("tcp://*:" + _listenPort);
_runServer = true;
_serverThread.Start();
ServerRunning = true;
}