Example #1
0
File: Udp.cs Project: doruu12/NetUV
        void QueueSend(BufferRef bufferRef,
                       IPEndPoint remoteEndPoint,
                       Action <Udp, Exception> completion)
        {
            Contract.Requires(remoteEndPoint != null);
            Contract.Requires(bufferRef != null);

            try
            {
                SendRequest request = Recycler.Take();
                Debug.Assert(request != null);
                request.Prepare(bufferRef,
                                (sendRequest, exception) => completion?.Invoke(this, exception));

                uv_buf_t[] bufs = request.Bufs;
                NativeMethods.UdpSend(
                    request.InternalHandle,
                    this.InternalHandle,
                    remoteEndPoint,
                    ref bufs);
            }
            catch (Exception exception)
            {
                Log.Error($"{this.HandleType} faulted.", exception);
                throw;
            }
        }