// Token: 0x06001867 RID: 6247 RVA: 0x000647A4 File Offset: 0x000629A4 public Exception StartListening(TcpListener.Config cfg) { bool flag = false; Exception ex = null; if (this.m_started) { throw new ArgumentException("TcpListener is one time only"); } try { this.ListenerConfig = cfg; this.m_started = true; this.m_listenSocket = new Socket(AddressFamily.InterNetworkV6, SocketType.Stream, ProtocolType.Tcp); this.m_listenSocket.SetSocketOption(SocketOptionLevel.IPv6, SocketOptionName.IPv6Only, 0); this.m_listenSocket.ReceiveBufferSize = cfg.ReceiveBufferSize; this.m_listenSocket.SendBufferSize = cfg.SendBufferSize; IPEndPoint localEP = new IPEndPoint(IPAddress.IPv6Any, cfg.ListenPort); this.m_listenSocket.Bind(localEP); int maxValue = int.MaxValue; this.m_listenSocket.Listen(maxValue); this.m_listenSocket.BeginAccept(new AsyncCallback(TcpListener.AcceptCallback), this); this.m_idleTimer = TcpListener.IdleTimer.CreateTimer(this); this.m_idleTimer.Start(); flag = true; TcpListener.Tracer.TraceDebug <int>((long)this.GetHashCode(), "Listening on port {0}", cfg.ListenPort); ReplayCrimsonEvents.TcpListenerStarted.Log <int>(cfg.ListenPort); } catch (NetworkTransportException ex2) { ex = ex2; } catch (SocketException ex3) { ex = ex3; } finally { if (!flag) { TcpListener.Tracer.TraceError <Exception>((long)this.GetHashCode(), "StartListening failed: {0}", ex); this.m_listenSocket.Close(); this.m_listenSocket = null; } } return(ex); }
// Token: 0x06002397 RID: 9111 RVA: 0x000A6BF8 File Offset: 0x000A4DF8 public static bool StartListening(bool useExchangeSid = true) { ExTraceGlobals.MonitoredDatabaseTracer.TraceDebug(0L, "Network TCP listener start listening."); bool result; lock (RemoteDataProvider.s_singletonLock) { if (RemoteDataProvider.s_initialized) { ExTraceGlobals.MonitoredDatabaseTracer.TraceDebug(0L, "StartListening returned because it is already initialized"); result = RemoteDataProvider.s_initialized; } else if (ThirdPartyManager.IsInitialized && ThirdPartyManager.IsThirdPartyReplicationEnabled) { RemoteDataProvider.s_tprEnabled = true; ExTraceGlobals.MonitoredDatabaseTracer.TraceDebug(0L, "StartListening does nothing because TPR is enabled"); result = true; } else { RemoteDataProvider.s_tprEnabled = false; if (RemoteDataProvider.s_selfCheckTimer == null) { RemoteDataProvider.s_selfCheckTimer = new Timer(new TimerCallback(RemoteDataProvider.SelfCheck), null, RegistryParameters.RemoteDataProviderSelfCheckInterval, RegistryParameters.RemoteDataProviderSelfCheckInterval); } try { if (useExchangeSid) { RemoteDataProvider.s_exchangeGroupSid = ObjectSecurity.ExchangeServersUsgSid; } if (RemoteDataProvider.s_tcpListener == null) { TcpListener.Config config = new TcpListener.Config(); config.ListenPort = (int)NetworkManager.GetReplicationPort(); config.LocalNodeName = Environment.MachineName; config.AuthConnectionHandOff = new TcpListener.AuthenticatedConnectionHandler(NetworkChannel.ServiceRequests); TcpListener tcpListener = new TcpListener(); Exception ex = tcpListener.StartListening(config); if (ex != null) { ReplayEventLogConstants.Tuple_TcpListenerFailedToStart.LogEvent(null, new object[] { ex }); ExTraceGlobals.MonitoredDatabaseTracer.TraceError <Exception>(0L, "Network TCP listener could not be started: {0}", ex); return(false); } RemoteDataProvider.s_tcpListener = tcpListener; } ClusterBatchWriter.Start(); RemoteDataProvider.s_initialized = true; ExTraceGlobals.MonitoredDatabaseTracer.TraceDebug(0L, "Network TCP listener successfully activated"); } catch (ADTransientException ex2) { ReplayEventLogConstants.Tuple_TcpListenerFailedToStart.LogEvent(null, new object[] { ex2 }); } catch (ADExternalException ex3) { ReplayEventLogConstants.Tuple_TcpListenerFailedToStart.LogEvent(null, new object[] { ex3 }); } catch (ADOperationException ex4) { ReplayEventLogConstants.Tuple_TcpListenerFailedToStart.LogEvent(null, new object[] { ex4 }); } finally { if (!RemoteDataProvider.s_initialized) { ClusterBatchWriter.Stop(); } } result = RemoteDataProvider.s_initialized; } } return(result); }