示例#1
0
        /// <summary>
        /// Send string message.
        /// </summary>
        /// <param name="message"></param>
        public void SendMessage(string message)
        {
            Frame updateFrame
                = new Frame(Encoding.UTF8.GetBytes(message));

            _socket.Send(updateFrame);
        }
示例#2
0
        /// <summary>
        /// Queue a single-part (or final multi-part) message buffer to be sent by the socket in
        /// non-blocking mode with a specified timeout.
        /// </summary>
        /// <remarks>
        /// This method assumes that the message fills the entire buffer.
        /// </remarks>
        /// <param name="socket">A <see cref="ZmqSocket"/> object.</param>
        /// <param name="buffer">A <see cref="byte"/> array that contains the message to be sent.</param>
        /// <param name="timeout">A <see cref="TimeSpan"/> specifying the send timeout.</param>
        /// <returns>A <see cref="SendStatus"/> describing the outcome of the send operation.</returns>
        /// <exception cref="ArgumentNullException"><paramref name="buffer"/> is null.</exception>
        /// <exception cref="ZmqSocketException">An error occurred sending data to a remote endpoint.</exception>
        /// <exception cref="ObjectDisposedException">The <see cref="ZmqSocket"/> has been closed.</exception>
        /// <exception cref="NotSupportedException">The current socket type does not support Send operations.</exception>
        public static SendStatus Send(this ZmqSocket socket, byte[] buffer, TimeSpan timeout)
        {
            VerifySocket(socket);

            socket.Send(buffer, buffer.Length, SocketFlags.None, timeout);

            return(socket.SendStatus);
        }
示例#3
0
        /// <summary>
        /// Queue a message frame to be sent by the socket in non-blocking mode with a specified timeout.
        /// </summary>
        /// <remarks>
        /// The <see cref="Frame.HasMore"/> property on <paramref name="frame"/> will be used to indicate whether
        /// more frames will follow in the current multi-part message sequence.
        /// </remarks>
        /// <param name="socket">A <see cref="ZmqSocket"/> object.</param>
        /// <param name="frame">A <see cref="Frame"/> that contains the message to be sent.</param>
        /// <param name="timeout">A <see cref="TimeSpan"/> specifying the send timeout.</param>
        /// <returns>A <see cref="SendStatus"/> describing the outcome of the send operation.</returns>
        /// <exception cref="ArgumentNullException"><paramref name="frame"/> is null.</exception>
        /// <exception cref="ZmqSocketException">An error occurred sending data to a remote endpoint.</exception>
        /// <exception cref="ObjectDisposedException">The <see cref="ZmqSocket"/> has been closed.</exception>
        /// <exception cref="NotSupportedException">The current socket type does not support Send operations.</exception>
        public static SendStatus SendFrame(this ZmqSocket socket, Frame frame, TimeSpan timeout)
        {
            VerifySocket(socket);
            VerifyFrame(frame);

            socket.Send(frame.Buffer, frame.MessageSize, frame.HasMore ? SocketFlags.SendMore : SocketFlags.None, timeout);

            return(socket.SendStatus);
        }
示例#4
0
        /// <summary>
        /// Queue a single-part (or final multi-part) message string to be sent by the socket in
        /// non-blocking mode with a specified timeout.
        /// </summary>
        /// <param name="socket">A <see cref="ZmqSocket"/> object.</param>
        /// <param name="message">A <see cref="string"/> that contains the message to be sent.</param>
        /// <param name="encoding">The <see cref="Encoding"/> to use when converting <paramref name="message"/> to a buffer.</param>
        /// <param name="timeout">A <see cref="TimeSpan"/> specifying the send timeout.</param>
        /// <returns>A <see cref="SendStatus"/> describing the outcome of the send operation.</returns>
        /// <exception cref="ArgumentNullException"><paramref name="message"/> or <paramref name="encoding"/> is null.</exception>
        /// <exception cref="ZmqSocketException">An error occurred sending data to a remote endpoint.</exception>
        /// <exception cref="ObjectDisposedException">The <see cref="ZmqSocket"/> has been closed.</exception>
        /// <exception cref="NotSupportedException">The current socket type does not support Send operations.</exception>
        public static SendStatus Send(this ZmqSocket socket, string message, Encoding encoding, TimeSpan timeout)
        {
            VerifySocket(socket);
            VerifyStringMessage(message);
            VerifyEncoding(encoding);

            byte[] buffer = encoding.GetBytes(message);

            socket.Send(buffer, buffer.Length, SocketFlags.None, timeout);

            return(socket.SendStatus);
        }