ConvertTransferException() статический приватный Метод

The Channel layer normalizes exceptions thrown by the underlying networking implementations into subclasses of CommunicationException, so that Channels can be used polymorphically from an exception handling perspective.
static private ConvertTransferException ( SocketException socketException ) : System.ServiceModel.CommunicationException
socketException System.Net.Sockets.SocketException
Результат System.ServiceModel.CommunicationException
Пример #1
0
            public SendAsyncResult(UdpOutputChannel channel, Message message, AsyncCallback callback, object state)
                : base(callback, state)
            {
                this.channel       = channel;
                this.messageBuffer = channel.EncodeMessage(message);
                try
                {
                    IAsyncResult result = null;
                    try
                    {
                        result = channel.socket.BeginSendTo(messageBuffer.Array, messageBuffer.Offset, messageBuffer.Count,
                                                            SocketFlags.None, channel.remoteEndPoint, new AsyncCallback(OnSend), this);
                    }
                    catch (SocketException socketException)
                    {
                        throw UdpChannelHelpers.ConvertTransferException(socketException);
                    }

                    if (!result.CompletedSynchronously)
                    {
                        return;
                    }

                    CompleteSend(result, true);
                }
                catch
                {
                    CleanupBuffer();
                    throw;
                }
            }
Пример #2
0
        public void Send(Message message)
        {
            base.ThrowIfDisposedOrNotOpen();

            ArraySegment <byte> messageBuffer = EncodeMessage(message);

            try
            {
                int bytesSent = this.socket.SendTo(messageBuffer.Array, messageBuffer.Offset, messageBuffer.Count,
                                                   SocketFlags.None, this.remoteEndPoint);

                if (bytesSent != messageBuffer.Count)
                {
                    throw new CommunicationException(string.Format(CultureInfo.CurrentCulture,
                                                                   "A Udp error occurred sending a message to {0}.", this.remoteEndPoint));
                }
            }
            catch (SocketException socketException)
            {
                throw UdpChannelHelpers.ConvertTransferException(socketException);
            }
            finally
            {
                // we need to make sure buffers are always returned to the BufferManager
                parent.BufferManager.ReturnBuffer(messageBuffer.Array);
            }
        }
Пример #3
0
            void CompleteSend(IAsyncResult result, bool synchronous)
            {
                try
                {
                    int bytesSent = channel.socket.EndSendTo(result);

                    if (bytesSent != messageBuffer.Count)
                    {
                        throw new CommunicationException(string.Format(CultureInfo.CurrentCulture,
                                                                       "A Udp error occurred sending a message to {0}.", channel.remoteEndPoint));
                    }
                }
                catch (SocketException socketException)
                {
                    throw UdpChannelHelpers.ConvertTransferException(socketException);
                }
                finally
                {
                    CleanupBuffer();
                }

                base.Complete(synchronous);
            }