protected int SendStreamImpl(NanomsgWriteStream stream, SendRecvFlags flags) { unsafe { int bufferCount = stream.PageCount; nn_iovec * iovec = stackalloc nn_iovec[bufferCount]; nn_msghdr *hdr = stackalloc nn_msghdr[1]; var buffer = stream.FirstPage(); int i = 0; do { iovec[i].iov_len = buffer.Length; iovec[i].iov_base = (void *)buffer.Buffer; buffer = stream.NextPage(buffer); } while (buffer.Buffer != IntPtr.Zero && i++ < bufferCount); (*hdr).msg_control = null; (*hdr).msg_controllen = 0; (*hdr).msg_iov = iovec; (*hdr).msg_iovlen = bufferCount; return(Interop.nn_sendmsg(SocketID, hdr, (int)flags)); } }
internal unsafe void SendMessage(nn_msghdr *messageHeader) { int sentBytes = Interop.nn_sendmsg(_socket, messageHeader, (int)SendRecvFlags.NONE); if (sentBytes < 0) { throw new NanomsgException("nn_send"); } }