Comments (11)
You can use the monitor directly or from Poller, anyway take a look at the
tests:
https://github.com/zeromq/netmq/blob/master/src/NetMQ.Tests/MonitorPollTests.cs
https://github.com/zeromq/netmq/blob/master/src/NetMQ.Tests/PollerTests.cs
On Mon, Aug 26, 2013 at 2:45 PM, meraydin [email protected] wrote:
I suppose this class is responsible for socket_connected,
socket_disconnected, v.s. events. Is there any sample code about how to use
this in a PUB/SUB model? (I'm looking for subscriber connected,
disconnected events)—
Reply to this email directly or view it on GitHubhttps://github.com//issues/97
.
from netmq.
Hi Doron,
Thanks for the reply. I was trying to find my way on those samples ☹ I suppose I can use this with Publisher socket type too, am I right?
From: Doron Somech [mailto:[email protected]]
Sent: Monday, August 26, 2013 3:28 PM
To: zeromq/netmq
Cc: Murat Eraydın
Subject: Re: [netmq] NetMQMonitor sample (#97)
You can use the monitor directly or from Poller, anyway take a look at the
tests:
https://github.com/zeromq/netmq/blob/master/src/NetMQ.Tests/MonitorPollTests.cs
https://github.com/zeromq/netmq/blob/master/src/NetMQ.Tests/PollerTests.cs
On Mon, Aug 26, 2013 at 2:45 PM, meraydin <[email protected]mailto:[email protected]> wrote:
I suppose this class is responsible for socket_connected,
socket_disconnected, v.s. events. Is there any sample code about how to use
this in a PUB/SUB model? (I'm looking for subscriber connected,
disconnected events)—
Reply to this email directly or view it on GitHubhttps://github.com//issues/97
.
—
Reply to this email directly or view it on GitHubhttps://github.com//issues/97#issuecomment-23259052.
from netmq.
Yes of course.
On Mon, Aug 26, 2013 at 3:33 PM, meraydin [email protected] wrote:
Hi Doron,
Thanks for the reply. I was trying to find my way on those samples ☹ I
suppose I can use this with Publisher socket type too, am I right?From: Doron Somech [mailto:[email protected]]
Sent: Monday, August 26, 2013 3:28 PM
To: zeromq/netmq
Cc: Murat Eraydın
Subject: Re: [netmq] NetMQMonitor sample (#97)You can use the monitor directly or from Poller, anyway take a look at the
tests:https://github.com/zeromq/netmq/blob/master/src/NetMQ.Tests/MonitorPollTests.cs
https://github.com/zeromq/netmq/blob/master/src/NetMQ.Tests/PollerTests.cs
On Mon, Aug 26, 2013 at 2:45 PM, meraydin <[email protected]
mailto:[email protected]> wrote:I suppose this class is responsible for socket_connected,
socket_disconnected, v.s. events. Is there any sample code about how to
use
this in a PUB/SUB model? (I'm looking for subscriber connected,
disconnected events)—
Reply to this email directly or view it on GitHub<
https://github.com/zeromq/netmq/issues/97>
.—
Reply to this email directly or view it on GitHub<
https://github.com/zeromq/netmq/issues/97#issuecomment-23259052>.—
Reply to this email directly or view it on GitHubhttps://github.com//issues/97#issuecomment-23259289
.
from netmq.
Here is the sample code I’ve come up... You can publish it somewhere if you wish... Just one more thing... How can I use this from another event? Let’s say a timer ticks and I want to send something to all subscribers... what is the safest way?
using System;
using System.Threading.Tasks;
using System.Threading;
using NetMQ;
using NetMQ.Monitoring;
using NetMQ.zmq;
namespace Publisher
{
class Program
{
static void Main(string[] args)
{
using (NetMQContext context = NetMQContext.Create())
{
Task serverTask = Task.Factory.StartNew(() => Server(context));
Task.WaitAll(serverTask);
}
}
static void Server(NetMQContext context)
{
using (var pub = context.CreatePublisherSocket())
{
using (NetMQMonitor monitor = new NetMQMonitor(context, pub, "inproc://pub.inproc", SocketEvent.Accepted | SocketEvent.Listening | SocketEvent.Disconnected ))
{
// for publisher/subscriber mode, only the following events happen
monitor.Accepted += new EventHandler<NetMQMonitorSocketEventArgs>(monitor_Accepted);
monitor.Listening += new EventHandler<NetMQMonitorSocketEventArgs>(monitor_Listening);
monitor.Disconnected += new EventHandler<NetMQMonitorSocketEventArgs>(monitor_Disconnected);
monitor.Timeout = TimeSpan.FromMilliseconds(100);
// be careful with the event handlers, if an exception is thrown, monitor will die!
var pollerTask = Task.Factory.StartNew(monitor.Start);
// publisher uses 'bind' (subscriber uses 'connect')
pub.Bind("tcp://*:5002");
pub.Options.DelayAttachOnConnect = false;
for (int i = 0; i < 1000; i++)
{
pub.Send("Hello" + i.ToString());
Thread.Sleep(25);
}
}
}
}
static void monitor_Disconnected(object sender, NetMQMonitorSocketEventArgs e)
{
Console.WriteLine("Disconnected: " + e.Socket.RemoteEndPoint.ToString());
}
static void monitor_Listening(object sender, NetMQMonitorSocketEventArgs e)
{
Console.WriteLine("Listening on: " + e.Socket.LocalEndPoint.ToString());
}
static void monitor_Accepted(object sender, NetMQMonitorSocketEventArgs e)
{
Console.WriteLine("Accepted: " + e.Socket.RemoteEndPoint.ToString());
}
}
}
From: Doron Somech [mailto:[email protected]]
Sent: Monday, August 26, 2013 3:55 PM
To: zeromq/netmq
Cc: Murat Eraydın
Subject: Re: [netmq] NetMQMonitor sample (#97)
Yes of course.
On Mon, Aug 26, 2013 at 3:33 PM, meraydin <[email protected]mailto:[email protected]> wrote:
Hi Doron,
Thanks for the reply. I was trying to find my way on those samples ☹ I
suppose I can use this with Publisher socket type too, am I right?From: Doron Somech [mailto:[email protected]]
Sent: Monday, August 26, 2013 3:28 PM
To: zeromq/netmq
Cc: Murat Eraydın
Subject: Re: [netmq] NetMQMonitor sample (#97)You can use the monitor directly or from Poller, anyway take a look at the
tests:https://github.com/zeromq/netmq/blob/master/src/NetMQ.Tests/MonitorPollTests.cs
https://github.com/zeromq/netmq/blob/master/src/NetMQ.Tests/PollerTests.cs
On Mon, Aug 26, 2013 at 2:45 PM, meraydin <[email protected]
mailto:[email protected]%20%0b> mailto:[email protected]> wrote:I suppose this class is responsible for socket_connected,
socket_disconnected, v.s. events. Is there any sample code about how to
use
this in a PUB/SUB model? (I'm looking for subscriber connected,
disconnected events)—
Reply to this email directly or view it on GitHub<
https://github.com/zeromq/netmq/issues/97>
.—
Reply to this email directly or view it on GitHub<
https://github.com/zeromq/netmq/issues/97#issuecomment-23259052>.—
Reply to this email directly or view it on GitHubhttps://github.com//issues/97#issuecomment-23259289
.
—
Reply to this email directly or view it on GitHubhttps://github.com//issues/97#issuecomment-23260390.
from netmq.
To use timer with monitoring take a look at the poller class, I sent you
the link in the last email.
On Aug 26, 2013 4:18 PM, "meraydin" [email protected] wrote:
Here is the sample code I’ve come up... You can publish it somewhere if
you wish... Just one more thing... How can I use this from another event?
Let’s say a timer ticks and I want to send something to all subscribers...
what is the safest way?using System;
using System.Threading.Tasks;
using System.Threading;
using NetMQ;
using NetMQ.Monitoring;
using NetMQ.zmq;namespace Publisher
{
class Program
{
static void Main(string[] args)
{
using (NetMQContext context = NetMQContext.Create())
{
Task serverTask = Task.Factory.StartNew(() => Server(context));
Task.WaitAll(serverTask);
}
}static void Server(NetMQContext context)
{
using (var pub = context.CreatePublisherSocket())
{
using (NetMQMonitor monitor = new NetMQMonitor(context, pub,
"inproc://pub.inproc", SocketEvent.Accepted | SocketEvent.Listening |
SocketEvent.Disconnected ))
{
// for publisher/subscriber mode, only the following events happen
monitor.Accepted += new
EventHandler(monitor_Accepted);
monitor.Listening += new
EventHandler(monitor_Listening);
monitor.Disconnected += new
EventHandler(monitor_Disconnected);monitor.Timeout = TimeSpan.FromMilliseconds(100);
// be careful with the event handlers, if an exception is thrown, monitor
will die!
var pollerTask = Task.Factory.StartNew(monitor.Start);// publisher uses 'bind' (subscriber uses 'connect')
pub.Bind("tcp://*:5002");
pub.Options.DelayAttachOnConnect = false;for (int i = 0; i < 1000; i++)
{
pub.Send("Hello" + i.ToString());
Thread.Sleep(25);
}
}
}
}static void monitor_Disconnected(object sender,
NetMQMonitorSocketEventArgs e)
{
Console.WriteLine("Disconnected: " + e.Socket.RemoteEndPoint.ToString());
}static void monitor_Listening(object sender, NetMQMonitorSocketEventArgs
e)
{
Console.WriteLine("Listening on: " + e.Socket.LocalEndPoint.ToString());
}static void monitor_Accepted(object sender, NetMQMonitorSocketEventArgs e)
{
Console.WriteLine("Accepted: " + e.Socket.RemoteEndPoint.ToString());
}
}
}From: Doron Somech [mailto:[email protected]]
Sent: Monday, August 26, 2013 3:55 PM
To: zeromq/netmq
Cc: Murat Eraydın
Subject: Re: [netmq] NetMQMonitor sample (#97)Yes of course.
On Mon, Aug 26, 2013 at 3:33 PM, meraydin <[email protected]
mailto:[email protected]> wrote:Hi Doron,
Thanks for the reply. I was trying to find my way on those samples ☹ I
suppose I can use this with Publisher socket type too, am I right?From: Doron Somech [mailto:[email protected]]
Sent: Monday, August 26, 2013 3:28 PM
To: zeromq/netmq
Cc: Murat Eraydın
Subject: Re: [netmq] NetMQMonitor sample (#97)You can use the monitor directly or from Poller, anyway take a look at
the
tests:https://github.com/zeromq/netmq/blob/master/src/NetMQ.Tests/MonitorPollTests.cs
https://github.com/zeromq/netmq/blob/master/src/NetMQ.Tests/PollerTests.cs
On Mon, Aug 26, 2013 at 2:45 PM, meraydin <[email protected]
mailto:[email protected]%20%0b> mailto:[email protected]>
wrote:I suppose this class is responsible for socket_connected,
socket_disconnected, v.s. events. Is there any sample code about how
to
use
this in a PUB/SUB model? (I'm looking for subscriber connected,
disconnected events)—
Reply to this email directly or view it on GitHub<
https://github.com/zeromq/netmq/issues/97>
.—
Reply to this email directly or view it on GitHub<
https://github.com/zeromq/netmq/issues/97#issuecomment-23259052>.—
Reply to this email directly or view it on GitHub<
https://github.com/zeromq/netmq/issues/97#issuecomment-23259289>
.—
Reply to this email directly or view it on GitHub<
https://github.com/zeromq/netmq/issues/97#issuecomment-23260390>.—
Reply to this email directly or view it on GitHubhttps://github.com//issues/97#issuecomment-23261569
.
from netmq.
I meant the timers.ttimer class... actually i want to subscribe to eventlog events and on logEntryWritten event I want to send them to subscribers. But 'using' blocks scares me. That's why i asked for a timer.tick sample so that i can convert that code.
Sent from Samsung Mobile
-------- Original message --------
From: Doron Somech [email protected]
Date:
To: zeromq/netmq [email protected]
Cc: Murat Eraydın [email protected]
Subject: Re: [netmq] NetMQMonitor sample (#97)
To use timer with monitoring take a look at the poller class, I sent you
the link in the last email.
On Aug 26, 2013 4:18 PM, "meraydin" [email protected] wrote:
Here is the sample code I’ve come up... You can publish it somewhere if
you wish... Just one more thing... How can I use this from another event?
Let’s say a timer ticks and I want to send something to all subscribers...
what is the safest way?using System;
using System.Threading.Tasks;
using System.Threading;
using NetMQ;
using NetMQ.Monitoring;
using NetMQ.zmq;namespace Publisher
{
class Program
{
static void Main(string[] args)
{
using (NetMQContext context = NetMQContext.Create())
{
Task serverTask = Task.Factory.StartNew(() => Server(context));
Task.WaitAll(serverTask);
}
}static void Server(NetMQContext context)
{
using (var pub = context.CreatePublisherSocket())
{
using (NetMQMonitor monitor = new NetMQMonitor(context, pub,
"inproc://pub.inproc", SocketEvent.Accepted | SocketEvent.Listening |
SocketEvent.Disconnected ))
{
// for publisher/subscriber mode, only the following events happen
monitor.Accepted += new
EventHandler(monitor_Accepted);
monitor.Listening += new
EventHandler(monitor_Listening);
monitor.Disconnected += new
EventHandler(monitor_Disconnected);monitor.Timeout = TimeSpan.FromMilliseconds(100);
// be careful with the event handlers, if an exception is thrown, monitor
will die!
var pollerTask = Task.Factory.StartNew(monitor.Start);// publisher uses 'bind' (subscriber uses 'connect')
pub.Bind("tcp://*:5002");
pub.Options.DelayAttachOnConnect = false;for (int i = 0; i < 1000; i++)
{
pub.Send("Hello" + i.ToString());
Thread.Sleep(25);
}
}
}
}static void monitor_Disconnected(object sender,
NetMQMonitorSocketEventArgs e)
{
Console.WriteLine("Disconnected: " + e.Socket.RemoteEndPoint.ToString());
}static void monitor_Listening(object sender, NetMQMonitorSocketEventArgs
e)
{
Console.WriteLine("Listening on: " + e.Socket.LocalEndPoint.ToString());
}static void monitor_Accepted(object sender, NetMQMonitorSocketEventArgs e)
{
Console.WriteLine("Accepted: " + e.Socket.RemoteEndPoint.ToString());
}
}
}From: Doron Somech [mailto:[email protected]]
Sent: Monday, August 26, 2013 3:55 PM
To: zeromq/netmq
Cc: Murat Eraydın
Subject: Re: [netmq] NetMQMonitor sample (#97)Yes of course.
On Mon, Aug 26, 2013 at 3:33 PM, meraydin <[email protected]
mailto:[email protected]> wrote:Hi Doron,
Thanks for the reply. I was trying to find my way on those samples ☹ I
suppose I can use this with Publisher socket type too, am I right?From: Doron Somech [mailto:[email protected]]
Sent: Monday, August 26, 2013 3:28 PM
To: zeromq/netmq
Cc: Murat Eraydın
Subject: Re: [netmq] NetMQMonitor sample (#97)You can use the monitor directly or from Poller, anyway take a look at
the
tests:https://github.com/zeromq/netmq/blob/master/src/NetMQ.Tests/MonitorPollTests.cs
https://github.com/zeromq/netmq/blob/master/src/NetMQ.Tests/PollerTests.cs
On Mon, Aug 26, 2013 at 2:45 PM, meraydin <[email protected]
mailto:[email protected]%20%0b> mailto:[email protected]>
wrote:I suppose this class is responsible for socket_connected,
socket_disconnected, v.s. events. Is there any sample code about how
to
use
this in a PUB/SUB model? (I'm looking for subscriber connected,
disconnected events)—
Reply to this email directly or view it on GitHub<
https://github.com/zeromq/netmq/issues/97>
.—
Reply to this email directly or view it on GitHub<
https://github.com/zeromq/netmq/issues/97#issuecomment-23259052>.—
Reply to this email directly or view it on GitHub<
https://github.com/zeromq/netmq/issues/97#issuecomment-23259289>
.—
Reply to this email directly or view it on GitHub<
https://github.com/zeromq/netmq/issues/97#issuecomment-23260390>.—
Reply to this email directly or view it on GitHubhttps://github.com//issues/97#issuecomment-23261569
.
—
Reply to this email directly or view it on GitHubhttps://github.com//issues/97#issuecomment-23284476.
from netmq.
To be more precise here is the code block I want to use NetMQ’s Publisher:
using System;
using System.Collections.Generic;
using System.Text;
using System.Diagnostics;
namespace EventLogTest
{
class Program
{
static void Main(string[] args)
{
EventLog log = new EventLog("System");
log.EntryWritten += new EntryWrittenEventHandler(log_EntryWritten);
log.EnableRaisingEvents = true;
Console.WriteLine("Press ENTER to exit");
Console.ReadLine();
}
static void log_EntryWritten(object sender, EntryWrittenEventArgs e)
{
Console.WriteLine(e.Entry.Message);
//how can I send e.Entry.Message to all subscribers?
//should I initialize the context and PublisherSocket globally or
//use a 'using' block here?
}
}
}
From: Murat Eraydın
Sent: 26 Ağustos 2013 Pazartesi 22:37
To: [email protected]; [email protected]
Cc: Murat Eraydın
Subject: Re: [netmq] NetMQMonitor sample (#97)
I meant the timers.ttimer class... actually i want to subscribe to eventlog events and on logEntryWritten event I want to send them to subscribers. But 'using' blocks scares me. That's why i asked for a timer.tick sample so that i can convert that code.
Sent from Samsung Mobile
-------- Original message --------
From: Doron Somech <[email protected]mailto:[email protected]>
Date:
To: zeromq/netmq <[email protected]mailto:[email protected]>
Cc: Murat Eraydın <[email protected]mailto:[email protected]>
Subject: Re: [netmq] NetMQMonitor sample (#97)
To use timer with monitoring take a look at the poller class, I sent you
the link in the last email.
On Aug 26, 2013 4:18 PM, "meraydin" <[email protected]mailto:[email protected]> wrote:
Here is the sample code I’ve come up... You can publish it somewhere if
you wish... Just one more thing... How can I use this from another event?
Let’s say a timer ticks and I want to send something to all subscribers...
what is the safest way?using System;
using System.Threading.Tasks;
using System.Threading;
using NetMQ;
using NetMQ.Monitoring;
using NetMQ.zmq;namespace Publisher
{
class Program
{
static void Main(string[] args)
{
using (NetMQContext context = NetMQContext.Create())
{
Task serverTask = Task.Factory.StartNew(() => Server(context));
Task.WaitAll(serverTask);
}
}static void Server(NetMQContext context)
{
using (var pub = context.CreatePublisherSocket())
{
using (NetMQMonitor monitor = new NetMQMonitor(context, pub,
"inproc://pub.inproc", SocketEvent.Accepted | SocketEvent.Listening |
SocketEvent.Disconnected ))
{
// for publisher/subscriber mode, only the following events happen
monitor.Accepted += new
EventHandler(monitor_Accepted);
monitor.Listening += new
EventHandler(monitor_Listening);
monitor.Disconnected += new
EventHandler(monitor_Disconnected);monitor.Timeout = TimeSpan.FromMilliseconds(100);
// be careful with the event handlers, if an exception is thrown, monitor
will die!
var pollerTask = Task.Factory.StartNew(monitor.Start);// publisher uses 'bind' (subscriber uses 'connect')
pub.Bind("tcp://*:5002");
pub.Options.DelayAttachOnConnect = false;for (int i = 0; i < 1000; i++)
{
pub.Send("Hello" + i.ToString());
Thread.Sleep(25);
}
}
}
}static void monitor_Disconnected(object sender,
NetMQMonitorSocketEventArgs e)
{
Console.WriteLine("Disconnected: " + e.Socket.RemoteEndPoint.ToString());
}static void monitor_Listening(object sender, NetMQMonitorSocketEventArgs
e)
{
Console.WriteLine("Listening on: " + e.Socket.LocalEndPoint.ToString());
}static void monitor_Accepted(object sender, NetMQMonitorSocketEventArgs e)
{
Console.WriteLine("Accepted: " + e.Socket.RemoteEndPoint.ToString());
}
}
}From: Doron Somech [mailto:[email protected]]
Sent: Monday, August 26, 2013 3:55 PM
To: zeromq/netmq
Cc: Murat Eraydın
Subject: Re: [netmq] NetMQMonitor sample (#97)Yes of course.
On Mon, Aug 26, 2013 at 3:33 PM, meraydin <[email protected]
mailto:[email protected]%20%0b> mailto:[email protected]> wrote:Hi Doron,
Thanks for the reply. I was trying to find my way on those samples ☹ I
suppose I can use this with Publisher socket type too, am I right?From: Doron Somech [mailto:[email protected]]
Sent: Monday, August 26, 2013 3:28 PM
To: zeromq/netmq
Cc: Murat Eraydın
Subject: Re: [netmq] NetMQMonitor sample (#97)You can use the monitor directly or from Poller, anyway take a look at
the
tests:https://github.com/zeromq/netmq/blob/master/src/NetMQ.Tests/MonitorPollTests.cs
https://github.com/zeromq/netmq/blob/master/src/NetMQ.Tests/PollerTests.cs
On Mon, Aug 26, 2013 at 2:45 PM, meraydin <[email protected]
mailto:[email protected]%20%0b> mailto:[email protected]%20%0b> mailto:[email protected]>
wrote:I suppose this class is responsible for socket_connected,
socket_disconnected, v.s. events. Is there any sample code about how
to
use
this in a PUB/SUB model? (I'm looking for subscriber connected,
disconnected events)—
Reply to this email directly or view it on GitHub<
https://github.com/zeromq/netmq/issues/97>
.—
Reply to this email directly or view it on GitHub<
https://github.com/zeromq/netmq/issues/97#issuecomment-23259052>.—
Reply to this email directly or view it on GitHub<
https://github.com/zeromq/netmq/issues/97#issuecomment-23259289>
.—
Reply to this email directly or view it on GitHub<
https://github.com/zeromq/netmq/issues/97#issuecomment-23260390>.—
Reply to this email directly or view it on GitHubhttps://github.com//issues/97#issuecomment-23261569
.
—
Reply to this email directly or view it on GitHubhttps://github.com//issues/97#issuecomment-23284476.
from netmq.
actually you should create the context and the publisher in the main
function, the only issue is that you don't know on what thread the event
run, Socket is not thread safe, you can lock on it in the event and then
call send, but it might suffer from performance if you have a lot of
events, if not (let's say less then 500 a second), you can go with the lock
solution.
On Mon, Aug 26, 2013 at 11:47 PM, meraydin [email protected] wrote:
To be more precise here is the code block I want to use NetMQ’s Publisher:
using System;
using System.Collections.Generic;
using System.Text;
using System.Diagnostics;namespace EventLogTest
{
class Program
{
static void Main(string[] args)
{
EventLog log = new EventLog("System");
log.EntryWritten += new EntryWrittenEventHandler(log_EntryWritten);
log.EnableRaisingEvents = true;
Console.WriteLine("Press ENTER to exit");
Console.ReadLine();
}static void log_EntryWritten(object sender, EntryWrittenEventArgs e)
{
Console.WriteLine(e.Entry.Message);
//how can I send e.Entry.Message to all subscribers?
//should I initialize the context and PublisherSocket globally or
//use a 'using' block here?
}
}
}From: Murat Eraydın
Sent: 26 Ağustos 2013 Pazartesi 22:37
To: [email protected]; [email protected]
Cc: Murat Eraydın
Subject: Re: [netmq] NetMQMonitor sample (#97)I meant the timers.ttimer class... actually i want to subscribe to
eventlog events and on logEntryWritten event I want to send them to
subscribers. But 'using' blocks scares me. That's why i asked for a
timer.tick sample so that i can convert that code.Sent from Samsung Mobile
-------- Original message --------
From: Doron Somech <[email protected]<mailto:
[email protected]>>
Date:
To: zeromq/netmq <[email protected]mailto:[email protected]>Cc: Murat Eraydın <[email protected]<mailto:
[email protected]>>
Subject: Re: [netmq] NetMQMonitor sample (#97)To use timer with monitoring take a look at the poller class, I sent you
the link in the last email.
On Aug 26, 2013 4:18 PM, "meraydin" <[email protected]<mailto:
[email protected]>> wrote:Here is the sample code I’ve come up... You can publish it somewhere if
you wish... Just one more thing... How can I use this from another
event?
Let’s say a timer ticks and I want to send something to all
subscribers...
what is the safest way?using System;
using System.Threading.Tasks;
using System.Threading;
using NetMQ;
using NetMQ.Monitoring;
using NetMQ.zmq;namespace Publisher
{
class Program
{
static void Main(string[] args)
{
using (NetMQContext context = NetMQContext.Create())
{
Task serverTask = Task.Factory.StartNew(() => Server(context));
Task.WaitAll(serverTask);
}
}static void Server(NetMQContext context)
{
using (var pub = context.CreatePublisherSocket())
{
using (NetMQMonitor monitor = new NetMQMonitor(context, pub,
"inproc://pub.inproc", SocketEvent.Accepted | SocketEvent.Listening |
SocketEvent.Disconnected ))
{
// for publisher/subscriber mode, only the following events happen
monitor.Accepted += new
EventHandler(monitor_Accepted);
monitor.Listening += new
EventHandler(monitor_Listening);
monitor.Disconnected += new
EventHandler(monitor_Disconnected);monitor.Timeout = TimeSpan.FromMilliseconds(100);
// be careful with the event handlers, if an exception is thrown,
monitor
will die!
var pollerTask = Task.Factory.StartNew(monitor.Start);// publisher uses 'bind' (subscriber uses 'connect')
pub.Bind("tcp://*:5002");
pub.Options.DelayAttachOnConnect = false;for (int i = 0; i < 1000; i++)
{
pub.Send("Hello" + i.ToString());
Thread.Sleep(25);
}
}
}
}static void monitor_Disconnected(object sender,
NetMQMonitorSocketEventArgs e)
{
Console.WriteLine("Disconnected: " +
e.Socket.RemoteEndPoint.ToString());
}static void monitor_Listening(object sender, NetMQMonitorSocketEventArgs
e)
{
Console.WriteLine("Listening on: " + e.Socket.LocalEndPoint.ToString());
}static void monitor_Accepted(object sender, NetMQMonitorSocketEventArgs
e)
{
Console.WriteLine("Accepted: " + e.Socket.RemoteEndPoint.ToString());
}
}
}From: Doron Somech [mailto:[email protected]]
Sent: Monday, August 26, 2013 3:55 PM
To: zeromq/netmq
Cc: Murat Eraydın
Subject: Re: [netmq] NetMQMonitor sample (#97)Yes of course.
On Mon, Aug 26, 2013 at 3:33 PM, meraydin <[email protected]
mailto:[email protected]%20%0b> mailto:[email protected]>
wrote:Hi Doron,
Thanks for the reply. I was trying to find my way on those samples ☹ I
suppose I can use this with Publisher socket type too, am I right?From: Doron Somech [mailto:[email protected]]
Sent: Monday, August 26, 2013 3:28 PM
To: zeromq/netmq
Cc: Murat Eraydın
Subject: Re: [netmq] NetMQMonitor sample (#97)You can use the monitor directly or from Poller, anyway take a look at
the
tests:https://github.com/zeromq/netmq/blob/master/src/NetMQ.Tests/MonitorPollTests.cs
https://github.com/zeromq/netmq/blob/master/src/NetMQ.Tests/PollerTests.cs
On Mon, Aug 26, 2013 at 2:45 PM, meraydin <[email protected]
mailto:[email protected]%20%0b> mailto:[email protected]%20%0b>
mailto:[email protected]>
wrote:I suppose this class is responsible for socket_connected,
socket_disconnected, v.s. events. Is there any sample code about how
to
use
this in a PUB/SUB model? (I'm looking for subscriber connected,
disconnected events)—
Reply to this email directly or view it on GitHub<
https://github.com/zeromq/netmq/issues/97>
.—
Reply to this email directly or view it on GitHub<
https://github.com/zeromq/netmq/issues/97#issuecomment-23259052>.—
Reply to this email directly or view it on GitHub<
https://github.com/zeromq/netmq/issues/97#issuecomment-23259289>
.—
Reply to this email directly or view it on GitHub<
https://github.com/zeromq/netmq/issues/97#issuecomment-23260390>.—
Reply to this email directly or view it on GitHub<
https://github.com/zeromq/netmq/issues/97#issuecomment-23261569>
.—
Reply to this email directly or view it on GitHub<
https://github.com/zeromq/netmq/issues/97#issuecomment-23284476>.—
Reply to this email directly or view it on GitHubhttps://github.com//issues/97#issuecomment-23293358
.
from netmq.
As @somdoron already mentioned, the Socket class is not thread safe. That and the strong argument against locks in the Zmq Guide lead me to write this question on Stack Overflow , maybe the answers are can help you too @meraydin .
from netmq.
@meraydin can I close the issue?
from netmq.
Yes please. Thanks
From: Doron Somech [mailto:[email protected]]
Sent: 12 Aralık 2013 Perşembe 22:41
To: zeromq/netmq
Cc: Murat Eraydın
Subject: Re: [netmq] NetMQMonitor sample (#97)
@meraydinhttps://github.com/meraydin can I close the issue?
—
Reply to this email directly or view it on GitHubhttps://github.com//issues/97#issuecomment-30459602.
from netmq.
Related Issues (20)
- RobiniaDocs API Explorer
- ZMQ_ROUTER_NOTIFY this?
- Critical CVE-2021-24112
- Feature. NetMQSocket TryReceive with CancellationToken
- IPC not working between .net7 and .net461 HOT 1
- NetMQ.NetMQException: Exception of type 'NetMQ.NetMQException' was thrown at NetMQ.Core.Ctx.CreateSocket(ZmqSocketType type)
- netmq is missing NuGet package README file
- Setting RouterMandatory on RouterSocket causes InvalidException
- "Closed" callback is called after the "Connected" callback when changing socket address.
- SubscriberSocket System.InvalidOperationException: Operation already in progress
- Poller thorws exception when signal fails on Recv() when resource temporarily unavailable
- Fix Division by Zero Error in FairQueueing Class When m_active is Zero
- Leverage framework dependencies where possible HOT 4
- Mailbox.TryRead still throwing in debug mode
- Process crash due to an unhandled exception in Mechanism.Encode
- StreamSocket does not send empty connect/disconnect message when peers connect/disconnect HOT 2
- Update of license from LGPL to MPL
- whether NetMQ supports queue data persistence ?
- Simplest example doesn't work
- MQ Client fails at sending
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from netmq.