在NetMQ中发布/订阅时,如何接收字节。
我正在尝试使用来自byte[] ReceiveFrameBytes()的扩展ReceivingSocketExtensions,但我只是看不到intellisense。
我使用的是NetMQ,它是扩展的容器名称空间。我正在使用Nuget NetMq包(不确定它是否相关-我假设它与github版本相同)
http://netmq.readthedocs.org/en/latest/receiving-sending/
namespace WhoCares
{
using NetMQ; // the extension are in this namespace?
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Text;
using System.Threading;
public class Subscriber
{
private Thread _coreThread;
private NetMQContext _context;
private NetMQSocket _socket;
public bool IsRunning { get; private set; }
public void Run()
{
if (IsRunning)
throw new InvalidOperationException("Already running");
_context = NetMQContext.Create();
_socket = _context.CreateSubscriberSocket();
_socket.Options.ReceiveHighWatermark = 1000;
_socket.Connect("tcp://localhost:12345");
_socket.Subscribe("TopicA");
IsRunning = true;
Core();
}
private void Core()
{
_coreThread = Thread.CurrentThread;
while (true)
{
string messageReceived = _socket.ReceiveString();
string bytesReceived = _socket.ReceiveString(); // I dont want a string..im sending bytesReceived
// i want to use
byte[] _socket.ReceiveFrameBytes();// COMPILER ERROR.. ITS IN THE EXTENSION ?
}
}
}
}要解决这个问题,请使用NUGET软件包
_socket.ReceiveMessage().Pop().ToByteArray()发布于 2015-08-28 15:37:33
ReceiveFrameBytes是新的API,仅适用于nuget的最新预发行版或来自主版的构建。尝试使用接收或ReceiveBytes。
https://stackoverflow.com/questions/32269807
复制相似问题