本文整理汇总了C#中ZmqSocket类的典型用法代码示例。如果您正苦于以下问题:C# ZmqSocket类的具体用法?C# ZmqSocket怎么用?C# ZmqSocket使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
ZmqSocket类属于命名空间,在下文中一共展示了ZmqSocket类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C#代码示例。
示例1: SendMessage
public static void SendMessage(byte[] address, byte[] message, ZmqSocket socket)
{
ZmqMessage zmqMessage = new ZmqMessage();
zmqMessage.Append(new Frame(address));
zmqMessage.Append(new Frame(message));
socket.SendMessage(zmqMessage);
}
开发者ID:yonglehou,项目名称:Daytona,代码行数:7,代码来源:Program.cs
示例2: SendRequest
public static void SendRequest(Int32 request,ref ZmqSocket socket)
{
//ZmqSocket socket;
try
{
//socket = CreateSocket();
var message = new ZmqMessage();
message.Append(Encoding.UTF8.GetBytes(String.Format(" Hello {0}.", request)));
socket.SendMessage(message);
// TODO: add receive timeout as param
var dataResult = socket.ReceiveMessage();
Console.WriteLine(Encoding.UTF8.GetString(dataResult[0]));
Console.WriteLine(Encoding.UTF8.GetString(dataResult[1]));
}
catch (Exception ex)
{
socket.Close();
socket = CreateSocket();
Console.WriteLine(ex.ToString());
}
}
开发者ID:maslakov,项目名称:zmqtests,代码行数:26,代码来源:Program.cs
示例3: Service1
public Service1(ZmqSocket socket)
{
_timer.Interval = 3000;
_socket = socket;
InitializeComponent();
}
开发者ID:zhanfeifei,项目名称:ZeroMQDemo,代码行数:7,代码来源:Service1.cs
示例4: RecieverPollInHandler
private void RecieverPollInHandler(ZmqSocket reciever, ZmqSocket sender)
{
Thread.Sleep(100);
var fileToMeasure = reciever.Receive(Encoding.Unicode);
Int64 fileLength = 0;
FileStream fs = null;
try
{
fs = File.OpenRead(fileToMeasure);
fileLength = fs.Length;
}
catch (IOException)
{
}
finally
{
if (fs != null) fs.Dispose();
}
Console.Write(".");
sender.Send(fileLength.ToString(), Encoding.Unicode);
}
开发者ID:keithbloom,项目名称:blogposts-zeromq,代码行数:25,代码来源:TaskWorker.cs
示例5: Receive
public static KvMsg Receive(ZmqSocket subscriber)
{
var key = subscriber.Receive(Encoding.Unicode);
var sequence = BitConverter.ToInt64(Encoding.Unicode.GetBytes(subscriber.Receive(Encoding.Unicode)), 0);
var body = subscriber.Receive(Encoding.Unicode);
return new KvMsg(sequence, key, body);
}
开发者ID:Jay-Krish,项目名称:zguide,代码行数:8,代码来源:kvsimple.cs
示例6: Send
public void Send(ZmqSocket socket)
{
for (int index = frames.Count - 1; index > 0; index--)
{
socket.SendMore(frames[index]);
}
socket.Send(frames[0]);
}
开发者ID:Jay-Krish,项目名称:zguide,代码行数:9,代码来源:zmsg.cs
示例7: Receive
public void Receive(ZmqSocket ZmqSocket)
{
var zmqMessage = ZmqSocket.ReceiveMessage();
foreach (var frame in zmqMessage)
{
frames.Insert(0, frame.Buffer);
}
}
开发者ID:Jay-Krish,项目名称:zguide,代码行数:9,代码来源:zmsg.cs
示例8: SocketEventArgs
internal SocketEventArgs(ZmqSocket socket, PollEvents readyEvents)
{
if (socket == null)
{
throw new ArgumentNullException("socket");
}
this.Socket = socket;
this.ReceiveReady = readyEvents.HasFlag(PollEvents.PollIn);
this.SendReady = readyEvents.HasFlag(PollEvents.PollOut);
}
开发者ID:jasper22,项目名称:UbuntuUsbMonitor,代码行数:11,代码来源:SocketEventArgs.cs
示例9: Bind
public override void Bind(ZmqSocket socket, ZeroRoute config)
{
ZeroLog.LogInfo("push bind....");
foreach (var endPoint in config.ConnectEndPoints())
{
socket.Connect(endPoint);
ZeroLog.LogInfo("push bind....");
}
}
开发者ID:dzhendong,项目名称:Zero,代码行数:11,代码来源:PushService.cs
示例10: ReceiverPollInHandler
private static void ReceiverPollInHandler(ZmqSocket receiver, ZmqSocket sender)
{
string task = receiver.Receive(Encoding.Unicode);
// Simple progress indicator for the viewer;
Console.WriteLine("{0}.", task);
int sleepTime = Convert.ToInt32(task);
Thread.Sleep(sleepTime);
// Send 'result' to the sink
sender.Send("", Encoding.Unicode);
}
开发者ID:Jay-Krish,项目名称:zguide,代码行数:13,代码来源:taskwork2.cs
示例11: OnSendComplete
protected override OpStatus OnSendComplete(ZmqSocket Socket)
{
// Request-replay socket (REQ) should immideatly receive message just after 'send'
#if DEBUG
System.Console.WriteLine("[RequestReplaySocket] Before receiveng the package");
System.Console.WriteLine("[RequestReplaySocket] Current thread ID:" + System.Threading.Thread.CurrentThread.ManagedThreadId.ToString());
#endif
ZmqMessage okMessage = Socket.ReceiveMessage(TimeSpan.FromSeconds(1));
#if DEBUG
System.Console.WriteLine("[RequestReplaySocket] Replay message was received. Status is: " + Socket.ReceiveStatus.ToString());
#endif
return Socket.ReceiveStatus.Convert();
}
开发者ID:jasper22,项目名称:UbuntuUsbMonitor,代码行数:15,代码来源:RequestReplaySocket.cs
示例12: AddSocket
/// <summary>
/// Add a socket that will be polled for input/output events, depending on its capabilities.
/// </summary>
/// <param name="socket">The <see cref="ZmqSocket"/> to poll.</param>
/// <exception cref="ArgumentNullException"><paramref name="socket"/> is null.</exception>
/// <exception cref="ArgumentOutOfRangeException"><paramref name="socket"/> has no event handlers.</exception>
public void AddSocket(ZmqSocket socket)
{
if (socket == null)
{
throw new ArgumentNullException("socket");
}
var pollEvents = socket.GetPollEvents();
if (pollEvents == PollEvents.None)
{
throw new ArgumentOutOfRangeException("socket", "Unable to add socket without at least one handler.");
}
_pollableSockets.Add(new PollItem(socket.SocketHandle, pollEvents), socket);
}
开发者ID:krageon,项目名称:clrzmq,代码行数:22,代码来源:Poller.cs
示例13: ZmqMessageSender
internal ZmqMessageSender(Uri serviceUri)
{
context = ZmqContext.Create();
socket = context.CreateSocket(SocketType.REQ);
var address = string.Format("tcp://{0}:{1}", serviceUri.Host, serviceUri.Port);
socket.Connect(address);
}
开发者ID:yonglehou,项目名称:DistributedCommunicationDotNet,代码行数:7,代码来源:ZmqMessageSender.cs
示例14: ClientForm
public ClientForm()
{
InitializeComponent();
context = ZmqContext.Create();
client = context.CreateSocket(SocketType.REQ);
client.Connect("tcp://localhost:5555");
}
开发者ID:simonkang,项目名称:ZeroMQSample,代码行数:7,代码来源:ClientForm.cs
示例15: ZmqPublisher
public ZmqPublisher(string endpoint)
{
_endpoint = endpoint;
_context = ZmqContext.Create();
_socket = _context.CreateSocket(SocketType.PUB);
_socket.Bind(_endpoint);
}
开发者ID:modulexcite,项目名称:graveyard,代码行数:7,代码来源:ZmqPublisher.cs
示例16: 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");
}
开发者ID:jystic,项目名称:Triangles-in-space,代码行数:7,代码来源:MessageSender.cs
示例17: Subscriber
public Subscriber(string _guid, string _targetGuid, string _host, int _port, ZmqContext _ctx)
{
guid = _guid;
targetGuid = _targetGuid;
host = _host;
port = _port;
if (port > 0)
connectionString = String.Format("tcp://{0}:{1}", host, port);
else
connectionString = String.Format("inproc://{0}", targetGuid.ToLower());
buf = new byte[1024 * 1024];
subscribeChannels = new List<string>();
if (_ctx == null)
{
shardedCtx = false;
ctx = ZmqContext.Create();
}
else
{
shardedCtx = true;
ctx = _ctx;
}
socket = ctx.CreateSocket(SocketType.SUB);
if (log.IsDebugEnabled) log.DebugFormat("Subscriber connecting to: `{0}`", connectionString);
socket.Subscribe(Proxy.StringToByteArray(guid));
socket.Connect(connectionString);
socket.ReceiveHighWatermark = 1000000;
socket.ReceiveBufferSize = 128 * 1024;
lastActiveTime = Proxy.Unixtimestamp();
log.InfoFormat("Connected successfuly to: `{0}` `{1}`", connectionString, targetGuid);
}
开发者ID:h0x91b,项目名称:ESB-csharp-server,代码行数:33,代码来源:Subscriber.cs
示例18: 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));
}
}
开发者ID:maslakov,项目名称:zmqtests,代码行数:28,代码来源:Program.cs
示例19: ZeroMqMessagePublisher
public ZeroMqMessagePublisher(ZmqContext context)
{
Console.WriteLine("Hey there");
_pub = context.CreateSocket(SocketType.PUB);
_pub.Bind("tcp://*:5555");
Console.WriteLine("Hello");
}
开发者ID:kijanawoodard,项目名称:NServiceBus.ZeroMQ,代码行数:8,代码来源:ZeroMqMessagePublisher.cs
示例20: 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);
}
开发者ID:jbouzaglou,项目名称:PetPigeonsESB,代码行数:8,代码来源:ZmqPullWireDataReceiver.cs
注:本文中的ZmqSocket类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论