Dispose() protected method

protected Dispose ( bool disposing ) : void
disposing bool
return void
Esempio n. 1
0
        protected override TTransport AcceptImpl()
        {
            if (server == null)
            {
                throw new TTransportException(TTransportException.ExceptionType.NotOpen, "No underlying server socket.");
            }
            try
            {
                TSocket result2 = null;
#if NETSTANDARD1_4 || NETSTANDARD1_5
                TcpClient result = server.AcceptTcpClientAsync().Result;
#else
                TcpClient result = server.AcceptTcpClient();
#endif
                try
                {
                    result2         = new TSocket(result);
                    result2.Timeout = clientTimeout;
                    if (useBufferedSockets)
                    {
#if NETSTANDARD1_4
                        throw new NotSupportedException("Not supported with NetStandard 1.4, use NetStandard 1.5 instead.");
#else
                        TBufferedTransport result3 = new TBufferedTransport(result2);
                        return(result3);
#endif
                    }
                    else
                    {
                        return(result2);
                    }
                }
                catch (System.Exception)
                {
                    // If a TSocket was successfully created, then let
                    // it do proper cleanup of the TcpClient object.
                    if (result2 != null)
                    {
                        result2.Dispose();
                    }
                    else //  Otherwise, clean it up ourselves.
                    {
                        ((IDisposable)result).Dispose();
                    }
                    throw;
                }
            }
            catch (Exception ex)
            {
                throw new TTransportException(ex.ToString());
            }
        }
Esempio n. 2
0
 protected override TTransport AcceptImpl()
 {
     if (server == null)
     {
         throw new TTransportException(TTransportException.ExceptionType.NotOpen, "No underlying server socket.");
     }
     try
     {
         TSocket   result2 = null;
         TcpClient result  = server.AcceptTcpClient();
         try
         {
             result2         = new TSocket(result);
             result2.Timeout = clientTimeout;
             if (useBufferedSockets)
             {
                 TBufferedTransport result3 = new TBufferedTransport(result2);
                 return(result3);
             }
             else
             {
                 return(result2);
             }
         }
         catch (System.Exception)
         {
             // If a TSocket was successfully created, then let
             // it do proper cleanup of the TcpClient object.
             if (result2 != null)
             {
                 result2.Dispose();
             }
             else //  Otherwise, clean it up ourselves.
             {
                 ((IDisposable)result).Dispose();
             }
             throw;
         }
     }
     catch (SocketException ex) when(ex.SocketErrorCode.Equals(SocketError.Interrupted))
     {
         throw new TTransportException(TTransportException.ExceptionType.Interrupted, ex.ToString());
     }
     catch (Exception ex)
     {
         throw new TTransportException(ex.ToString());
     }
 }
Esempio n. 3
0
        protected override TTransport AcceptImpl()
        {
            TTransport tBufferedTransport;

            if (this.server == null)
            {
                throw new TTransportException(TTransportException.ExceptionType.NotOpen, "No underlying server socket.");
            }
            try
            {
                TSocket tSocket = null;
                var     t       = this.server.AcceptTcpClientAsync();
                t.Wait();
                TcpClient tcpClient = t.Result;
                try
                {
                    tSocket = new TSocket(tcpClient)
                    {
                        Timeout = this.clientTimeout
                    };
                    if (!this.useBufferedSockets)
                    {
                        tBufferedTransport = tSocket;
                    }
                    else
                    {
                        tBufferedTransport = new TBufferedTransport(tSocket);
                    }
                }
                catch (Exception exception)
                {
                    if (tSocket == null)
                    {
                        ((IDisposable)tcpClient).Dispose();
                    }
                    else
                    {
                        tSocket.Dispose();
                    }
                    throw;
                }
            }
            catch (Exception exception1)
            {
                throw new TTransportException(exception1.ToString());
            }
            return(tBufferedTransport);
        }
Esempio n. 4
0
 protected override TTransport AcceptImpl()
 {
     if (server == null)
     {
         throw new TTransportException(TTransportException.ExceptionType.NotOpen, "No underlying server socket.");
     }
     try
     {
         TSocket result2 = null;
         TcpClient result = server.AcceptTcpClient();
         try
         {
             result2 = new TSocket(result);
             result2.Timeout = clientTimeout;
             if (useBufferedSockets)
             {
                 TBufferedTransport result3 = new TBufferedTransport(result2);
                 return result3;
             }
             else
             {
                 return result2;
             }
         }
         catch (System.Exception)
         {
             // If a TSocket was successfully created, then let 
             // it do proper cleanup of the TcpClient object.
             if (result2 != null)
                 result2.Dispose();
             else //  Otherwise, clean it up ourselves.
                 ((IDisposable)result).Dispose();
             throw;
         }
     }
     catch (Exception ex)
     {
         throw new TTransportException(ex.ToString());
     }
 }