Exemplo n.º 1
0
        /// <summary>
        /// Extends BeginSendTo so that when a state object is not needed, null does not need to be passed.
        /// <example>
        /// udpanysourcemulticastclient.BeginSendTo(buffer, offset, count, remoteEndPoint, callback);
        /// </example>
        /// </summary>
        public static IAsyncResult BeginSendTo(this UdpAnySourceMulticastClient udpanysourcemulticastclient, Byte[] buffer, Int32 offset, Int32 count, System.Net.IPEndPoint remoteEndPoint, AsyncCallback callback)
        {
            if (udpanysourcemulticastclient == null)
            {
                throw new ArgumentNullException("udpanysourcemulticastclient");
            }

            return(udpanysourcemulticastclient.BeginSendTo(buffer, offset, count, remoteEndPoint, callback, null));
        }
Exemplo n.º 2
0
 public bool Send(Message message, IPEndPoint ep)
 {
     try
     {
         byte[] byteMessage = message.GetBytes();
         client.BeginSendTo(byteMessage, 0, byteMessage.Length, ep, OnSendTo, null);
         return(true);
     }
     catch (Exception)
     {
         return(false);
     }
 }
Exemplo n.º 3
0
        /// <summary>
        /// Extends BeginSendTo so that buffer offset of 0 and call to Array.Length are not needed.
        /// <example>
        /// udpanysourcemulticastclient.BeginSendTo(buffer, remoteEndPoint, callback);
        /// </example>
        /// </summary>
        public static IAsyncResult BeginSendTo(this UdpAnySourceMulticastClient udpanysourcemulticastclient, Byte[] buffer, System.Net.IPEndPoint remoteEndPoint, AsyncCallback callback)
        {
            if (udpanysourcemulticastclient == null)
            {
                throw new ArgumentNullException("udpanysourcemulticastclient");
            }

            if (buffer == null)
            {
                throw new ArgumentNullException("buffer");
            }

            return(udpanysourcemulticastclient.BeginSendTo(buffer, 0, buffer.Length, remoteEndPoint, callback));
        }
Exemplo n.º 4
0
        public async Task <IObservable <Message> > ResolveAsync(string protocol)
        {
            ushort requestId = CreateRequestId();

            Message message = new Message(requestId);

            message.Questions.Add(new Question(protocol));

            byte[] byteMessage = message.GetBytes();

            await Task.Factory.FromAsync(
                (buffer, ep, callback, state) => client.BeginSendTo(buffer, 0, buffer.Length, ep, callback, state),
                client.EndSendTo,
                byteMessage,
                EndPoint,
                null);

            return(this.answers.Where(x => x.ID == requestId || x.ID == 0));
        }