本文整理汇总了C#中NetMQ.zmq.SocketBase类的典型用法代码示例。如果您正苦于以下问题:C# SocketBase类的具体用法?C# SocketBase怎么用?C# SocketBase使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
SocketBase类属于NetMQ.zmq命名空间,在下文中一共展示了SocketBase类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: PgmListener
public PgmListener(IOThread ioThread, SocketBase socket, Options options)
: base(ioThread, options)
{
m_socket = socket;
m_ioObject = new IOObject(ioThread);
}
示例2: SessionBase
public SessionBase(IOThread ioThread, bool connect,
SocketBase socket, Options options, Address addr)
: base(ioThread, options)
{
m_ioObject = new IOObject(ioThread);
m_connect = connect;
m_pipe = null;
m_incompleteIn = false;
m_pending = false;
m_engine = null;
m_socket = socket;
m_ioThread = ioThread;
m_hasLingerTimer = false;
m_identitySent = false;
m_identityReceived = false;
m_addr = addr;
if (options.RawSocket)
{
m_identitySent = true;
m_identityReceived = true;
}
m_terminatingPipes = new HashSet<Pipe>();
}
示例3: Read
public static MonitorEvent Read(SocketBase s)
{
Msg msg = s.Recv(0);
if (msg == null)
return null;
int pos = 0;
ByteArraySegment data = msg.Data;
SocketEvent @event =(SocketEvent) data.GetInteger(pos);
pos += 4;
int len = (int)data[pos++];
string addr = data.GetString(len, pos);
pos += len;
int flag = (int)data[pos++];
Object arg = null;
if (flag == ValueInteger)
{
arg = data.GetInteger(pos);
}
else if (flag == ValueChannel)
{
if (SizeOfIntPtr == 4)
{
arg = new IntPtr(data.GetInteger(pos));
}
else
{
arg = new IntPtr(data.GetLong(pos));
}
}
return new MonitorEvent(@event, addr, arg);
}
示例4: Close
public static void Close(SocketBase s)
{
if (s == null || !s.CheckTag())
{
throw new InvalidOperationException();
}
s.Close();
}
示例5: Close
public static void Close(SocketBase s)
{
if (s == null || !s.CheckTag())
{
throw NetMQException.Create(ErrorCode.EFAULT);
}
s.Close();
}
示例6: Connect
public static bool Connect(SocketBase s, String addr)
{
if (s == null || !s.CheckTag())
{
throw new InvalidOperationException();
}
return s.Connect(addr);
}
示例7: TcpListener
public TcpListener(IOThread ioThread, SocketBase socket, Options options)
: base(ioThread, options)
{
m_ioObject = new IOObject(ioThread);
m_address = new TcpAddress();
m_handle = null;
m_socket = socket;
}
示例8: BindRandomPort
public static int BindRandomPort(SocketBase s, String addr)
{
if (s == null || !s.CheckTag())
{
throw NetMQException.Create(ErrorCode.EFAULT);
}
return s.BindRandomPort(addr);
}
示例9: Connect
public static void Connect(SocketBase s, String addr)
{
if (s == null || !s.CheckTag())
{
throw NetMQException.Create(ErrorCode.EFAULT);
}
s.Connect(addr);
}
示例10: Read
public static MonitorEvent Read(SocketBase s)
{
Msg msg = s.Recv(0);
if (msg == null)
return null;
int pos = 0;
ByteArraySegment data = msg.Data;
SocketEvent @event = (SocketEvent)data.GetInteger(Endianness.Little, pos);
pos += 4;
int len = (int)data[pos++];
string addr = data.GetString(len, pos);
pos += len;
int flag = (int)data[pos++];
Object arg = null;
if (flag == ValueInteger)
{
arg = data.GetInteger(Endianness.Little, pos);
}
else if (flag == ValueChannel)
{
IntPtr value;
if (SizeOfIntPtr == 4)
{
value = new IntPtr(data.GetInteger(Endianness.Little, pos));
}
else
{
value = new IntPtr(data.GetLong(Endianness.Little, pos));
}
GCHandle handle = GCHandle.FromIntPtr(value);
Socket socket = null;
if (handle.IsAllocated)
{
socket = handle.Target as Socket;
}
handle.Free();
arg = socket;
}
return new MonitorEvent(@event, addr, arg);
}
示例11: RecvMsg
public static Msg RecvMsg(SocketBase s, SendReceiveOptions flags)
{
return s.Recv(flags);
}
示例12: SendIOv
// Send multiple messages.
//
// If flag bit ZMQ_SNDMORE is set the vector is treated as
// a single multi-part message, i.e. the last message has
// ZMQ_SNDMORE bit switched off.
//
public void SendIOv(SocketBase s, byte[][] a, int count, SendReceiveOptions flags)
{
if (s == null || !s.CheckTag())
{
throw NetMQException.Create(ErrorCode.EFAULT);
}
Msg msg;
for (int i = 0; i < count; ++i)
{
msg = new Msg(a[i]);
if (i == count - 1)
flags = flags & ~SendReceiveOptions.SendMore;
SendMsg(s, msg, flags);
}
}
示例13: SendMsg
private static void SendMsg(SocketBase s, Msg msg, SendReceiveOptions flags)
{
s.Send(msg, flags);
}
示例14: Unbind
public static bool Unbind(SocketBase s, String addr)
{
if (s == null || !s.CheckTag())
{
throw NetMQException.Create(ErrorCode.EFAULT);
}
return s.TermEndpoint(addr);
}
示例15: RecvIOv
// Receive a multi-part message
//
// Receives up to *count_ parts of a multi-part message.
// Sets *count_ to the actual number of parts read.
// ZMQ_RCVMORE is set to indicate if a complete multi-part message was read.
// Returns number of message parts read, or -1 on error.
//
// Note: even if -1 is returned, some parts of the message
// may have been read. Therefore the client must consult
// *count_ to retrieve message parts successfully read,
// even if -1 is returned.
//
// The iov_base* buffers of each iovec *a_ filled in by this
// function may be freed using free().
//
// Implementation note: We assume zmq::msg_t buffer allocated
// by zmq::recvmsg can be freed by free().
// We assume it is safe to steal these buffers by simply
// not closing the zmq::msg_t.
//
public int RecvIOv(SocketBase s, byte[][] a, int count, SendReceiveOptions flags)
{
if (s == null || !s.CheckTag())
{
throw NetMQException.Create(ErrorCode.EFAULT);
}
int nread = 0;
bool recvmore = true;
for (int i = 0; recvmore && i < count; ++i)
{
// Cheat! We never close any msg
// because we want to steal the buffer.
Msg msg = RecvMsg(s, flags);
if (msg == null)
{
nread = -1;
break;
}
// Cheat: acquire zmq_msg buffer.
a[i] = msg.Data;
// Assume zmq_socket ZMQ_RVCMORE is properly set.
recvmore = msg.HasMore;
}
return nread;
}