本文整理汇总了C#中Context.CreateSocket方法的典型用法代码示例。如果您正苦于以下问题:C# Context.CreateSocket方法的具体用法?C# Context.CreateSocket怎么用?C# Context.CreateSocket使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Context
的用法示例。
在下文中一共展示了Context.CreateSocket方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Main
public static void Main()
{
Context ctx = new Context(1, 1, 0);
Socket s = ctx.CreateSocket(SocketType.P2P);
s.Bind("tcp://127.0.0.1:5555");
while (true) {
Console.WriteLine("Received query: '{0}'", s.RecvString());
}
}
示例2: Main
public static void Main()
{
Context ctx = new Context(1, 1, 0);
Socket s = ctx.CreateSocket(SocketType.SUB);
s.SetSockOpt(SocketOption.SUBSCRIBE, IntPtr.Zero, 0);
s.Connect("tcp://127.0.0.1:5556");
while (true)
{
Console.WriteLine(s.RecvString());
}
}
示例3: Main
public static void Main()
{
Context ctx = new Context(1, 1, 0);
Socket s = ctx.CreateSocket(SocketType.PUB);
s.Bind("tcp://127.0.0.1:5555");
Encoding encoding = Encoding.GetEncoding("ASCII");
for (long msg_id = 1; msg_id < 50000; msg_id++)
{
s.SendString(msg_id.ToString(), encoding);
}
}
示例4: Main
public static int Main()
{
try {
Context ctx = new Context(1, 1, 0);
Socket s = ctx.CreateSocket(SocketType.P2P);
s.Connect("tcp://127.0.0.1:5555");
s.SendString("SELECT * FROM mytable");
} catch (ZmqException e) {
Console.WriteLine("An error occurred: {0}\n", e.Message);
return 1;
}
return 0;
}
示例5: Main
public static void Main()
{
Context ctx = new Context(1, 1, 0);
Socket s = ctx.CreateSocket(SocketType.PUB);
s.Bind("tcp://127.0.0.1:5555");
for (long msg_id = 1; ; msg_id++)
{
using (Message msg = new Message(8)) {
Marshal.WriteInt64(msg.Data, msg_id);
s.Send(msg, 0);
long tmp = Marshal.ReadInt64(msg.Data);
if ((tmp % 10000) == 0)
Console.WriteLine(tmp);
}
}
}
示例6: ForwarderDevice
/// <summary>
/// Initializes a new instance of the <see cref="ForwarderDevice"/> class.
/// </summary>
/// <param name="context">The <see cref="Context"/> to use when creating the sockets.</param>
/// <param name="mode">The <see cref="DeviceMode"/> for the current device.</param>
public ForwarderDevice(Context context, DeviceMode mode)
: base(context.CreateSocket(FrontendType), context.CreateSocket(BackendType), mode)
{
}