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());
}
}