using System;
using NetMQ.Core;
namespace NetMQ.Sockets
{
///
/// Peer socket, the first message is always the identity of the sender
///
public class PeerSocket : NetMQSocket
{
///
/// Create a new PeerSocket and attach socket to zero or more endpoints.
///
/// List of NetMQ endpoints, separated by commas and prefixed by '@' (to bind the socket) or '>' (to connect the socket).
/// Default action is connect (if endpoint doesn't start with '@' or '>')
/// var socket = new PeerSocket(">tcp://127.0.0.1:5555,>tcp://127.0.0.1:55556");
public PeerSocket(string? connectionString = null) : base(ZmqSocketType.Peer, connectionString, DefaultAction.Connect)
{
}
///
/// Create a new PeerSocket based upon the given SocketBase.
///
/// the SocketBase to create the new socket from
internal PeerSocket(SocketBase socketHandle) : base(socketHandle)
{
}
///
/// Connect the peer socket to .
///
/// a string denoting the address to connect this socket to
/// The peer allocated routing id
/// thrown if the socket was already disposed
/// The socket has been stopped.
/// No IO thread was found.
/// The specified address is already in use.
public byte[] ConnectPeer(string address)
{
Connect(address);
byte[]? routingId = GetSocketOptionX(ZmqSocketOption.LastPeerRoutingId);
Assumes.NotNull(routingId);
return routingId;
}
}
}