本文整理汇总了C#中ZmqSocket.Connect方法的典型用法代码示例。如果您正苦于以下问题:C# ZmqSocket.Connect方法的具体用法?C# ZmqSocket.Connect怎么用?C# ZmqSocket.Connect使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ZmqSocket
的用法示例。
在下文中一共展示了ZmqSocket.Connect方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: 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");
}
示例2: 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);
}
示例3: 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);
}
示例4: ClientForm
public ClientForm()
{
InitializeComponent();
context = ZmqContext.Create();
client = context.CreateSocket(SocketType.REQ);
client.Connect("tcp://localhost:5555");
}
示例5: ConnectSocket
public void ConnectSocket()
{
if (_socket != null)
{
return;
}
_socket = _context.CreateSocket(SocketType.SUB);
_socket.Subscribe(new byte[] {});
_socket.Connect(_endpoint);
}
示例6: 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....");
}
}
示例7: GrapevineSender
public GrapevineSender(ZmqContext context, string address, IMessageSerializer serializer)
{
_serializer = serializer;
_scheduler = new EventLoopScheduler();
_socket = context.CreateSocket(SocketType.PUB);
_socket.Connect(address);
_messages = new Subject<ZmqMessage>();
_messageDispatcher = _messages
.SubscribeOn(_scheduler)
.ObserveOn(_scheduler)
.Subscribe(msg => _socket.SendMessage(msg));
}
示例8: Connect
public void Connect()
{
_socket = _context.CreateSocket(SocketType.PUSH);
_socket.SendHighWatermark = _options.SendHighWaterMark;
_socket.TcpKeepalive = TcpKeepaliveBehaviour.Enable;
_socket.TcpKeepaliveIdle = 30;
_socket.TcpKeepaliveIntvl = 3;
_socket.SetPeerId(_peerId);
try
{
_socket.Connect(EndPoint);
}
catch
{
_socket.Dispose();
throw;
}
_logger.InfoFormat("Socket connected, Peer: {0}, EndPoint: {1}", _peerId, EndPoint);
_isConnected = true;
}
示例9: Start1
private static void Start1(Object cancelationToken)
{
router = context.CreateSocket(SocketType.REQ);
router.Connect("tcp://127.0.0.1:5000");
router.ReceiveReady += new EventHandler<SocketEventArgs>(router_ReceiveReady1);
router.SendReady += new EventHandler<SocketEventArgs>(router_SendReady);
Poller poller = new Poller(new[] { router });
var token = (CancellationToken)cancelationToken;
while (!token.IsCancellationRequested)
{
poller.Poll(TimeSpan.FromMilliseconds(100));
}
router.Disconnect("tcp://127.0.0.1:5000");
}
示例10: SetupController
private void SetupController(ZmqSocket controller)
{
controller.SubscribeAll();
controller.Connect("inproc://controller");
controller.ReceiveReady += (x, y) =>
{
//Console.WriteLine("I'm done for the day");
_work = false;
};
}
示例11: Initialize
public void Initialize()
{
ZmqContext = ZmqContext.Create();
Sender = ZmqContext.CreateSocket(_senderType);
Receiver = ZmqContext.CreateSocket(_receiverType);
_senderThread = new Thread(() =>
{
SenderInit(Sender);
Sender.SendHighWatermark = 1;
_receiverReady.WaitOne();
Sender.Connect("inproc://spec_context");
SenderAction(Sender);
});
_receiverThread = new Thread(() =>
{
ReceiverInit(Receiver);
Receiver.SendHighWatermark = 1;
Receiver.Bind("inproc://spec_context");
_receiverReady.Set();
ReceiverAction(Receiver);
});
StartThreads();
}
示例12: WorldView
public WorldView(ZmqContext zmqContext, string host, int port)
{
var worldUri = String.Format("tcp://{0}:{1}", host, port);
WorldSocket = zmqContext.CreateSocket(SocketType.REQ);
WorldSocket.Connect(worldUri);
}
示例13: Subscriber
public Subscriber(string _connectionString, string _proxyGuid, string ESBClientGuid)
{
connectionString = _connectionString;
buf = new byte[65536];
ctx = ZmqContext.Create();
socket = ctx.CreateSocket(SocketType.SUB);
var binGuid = ESBClient.stringToByteArray(ESBClientGuid);
channels = new List<string>();
//socket.SubscribeAll();
//socket.Subscribe(ASCIIEncoding.ASCII.GetBytes(""));
socket.Subscribe(binGuid);
socket.Connect(connectionString);
socket.ReceiveHighWatermark = 100000;
socket.ReceiveBufferSize = 256 * 1024;
}
示例14: processMessages
/// <summary>
/// Processes the incoming message queue.
/// </summary><remarks>
/// Runs on a worker thread.
/// </remarks>
private void processMessages()
{
// We create a socket to receive messages from the
// Python server...
m_receiveSocket = m_context.CreateSocket(SocketType.SUB);
m_receiveSocket.Connect("tcp://localhost:12345");
m_receiveSocket.SubscribeAll();
TimeSpan timeout = new TimeSpan(0, 0, 0, 0, 1);
while (m_stopThread == false)
{
// We see if there is a message...
int bytesReceived = m_receiveSocket.Receive(m_buffer, timeout);
if (bytesReceived == -1)
{
// There was no message in the queue...
continue;
}
// We got a message, so we decode it...
switch (m_buffer[0])
{
case 0:
// The 'Hello' message from the server...
handleHelloMessage();
break;
case 1:
// The start-of-tournament message...
decodeStartOfTournamentMessage(bytesReceived);
break;
case 2:
// The start-of-game message...
Utils.raiseEvent(StartOfGameEvent, this, null);
break;
case 3:
// The player-info message...
decodePlayerInfoMessage(bytesReceived);
break;
case 4:
// The board-update message...
decodeBoardUpdateMessage(bytesReceived);
break;
default:
// An unknown message (or maybe the "Hello" message after
// we connect. We ignore this...
break;
}
}
// We close the socket before exiting the thread...
m_receiveSocket.Linger = new TimeSpan(0);
m_receiveSocket.Dispose();
}
示例15: InitConnection
internal void InitConnection()
{
context = ZmqContext.Create();
SubData = context.CreateSocket(SocketType.SUB);
SubData.Connect("tcp://" + Global.Instance.DataConIp + ":" + Global.Instance.DataConSUBPort);
Subscribe();
Subscriber();
//
}