// Token: 0x06000B95 RID: 2965 RVA: 0x00033860 File Offset: 0x00031A60 private void GetChannel() { if (this.m_channel == null) { NetworkPath netPath = NetworkManager.ChooseNetworkPath(this.m_serverName, null, NetworkPath.ConnectionPurpose.Seeding); this.m_channel = NetworkChannel.Connect(netPath, TcpChannel.GetDefaultTimeoutInMs(), false); } }
public void TestChannelPackerErrorDecode() { var fromClient = new byte[] { }; using (var server = new TcpServer((data) => { fromClient = Arr.Merge(fromClient, data); })) { var socket = MakeEnv().Make <ISocketManager>().Make("tcp://127.0.0.1", "TestChannelPackerErrorDecode"); var channel = new NetworkChannel(socket, new PackerError(PackerError.ErrorType.Decode), "TestChannelPackerErrorDecode"); var wait = channel.Connect("127.0.0.1", 7777); var count = 0; while (!wait.IsDone && count++ < 3000) { Thread.Sleep(1); } try { string err = string.Empty; channel.OnError += (c, ex) => { if (err == string.Empty) { err = ex.ToString(); } }; channel.Send(Encoding.Default.GetBytes("helloworld")); count = 0; while (channel.Socket.Connected && count++ < 3000) { Thread.Sleep(1); } Assert.AreEqual(false, channel.Socket.Connected); Assert.AreEqual("CatLib.RuntimeException: exception decode", err); } finally { channel.Disconnect(); } } }
// Token: 0x06002242 RID: 8770 RVA: 0x0009FAAC File Offset: 0x0009DCAC public NetworkChannel OpenChannel() { string networkName = null; NetworkPath.ConnectionPurpose purpose = NetworkPath.ConnectionPurpose.LogCopy; NetworkPath netPath; if (this.m_initialNetworkPath == null) { netPath = NetworkManager.ChooseNetworkPath(this.m_sourceAddr, networkName, purpose); } else { netPath = this.m_initialNetworkPath; this.m_initialNetworkPath = null; } this.m_channel = NetworkChannel.Connect(netPath, base.DefaultTimeoutInMs, false); return(this.m_channel); }
// Token: 0x060019CD RID: 6605 RVA: 0x0006C134 File Offset: 0x0006A334 private void GetChannel() { lock (this) { if (this.isAborted) { throw new SeederOperationAbortedException(); } if (this.channel == null) { NetworkPath networkPath = NetworkManager.ChooseNetworkPath(this.sourceServerFqdn, this.NetworkName, NetworkPath.ConnectionPurpose.Seeding); if (this.CompressOverride != null || this.EncryptOverride != null || !string.IsNullOrEmpty(this.NetworkName)) { networkPath.Compress = (this.CompressOverride ?? networkPath.Compress); networkPath.Encrypt = (this.EncryptOverride ?? networkPath.Encrypt); networkPath.NetworkChoiceIsMandatory = true; } this.channel = NetworkChannel.Connect(networkPath, TcpChannel.GetDefaultTimeoutInMs(), false); } } }
public void TestChannelPackerErrorEncode() { var fromClient = new byte[] { }; using (var server = new TcpServer((data) => { fromClient = Arr.Merge(fromClient, data); })) { var socket = MakeEnv().Make <ISocketManager>().Make("tcp://127.0.0.1", "TestChannelPackerErrorEncode"); var channel = new NetworkChannel(socket, new PackerError(PackerError.ErrorType.Encode), "TestChannelPackerErrorEncode"); var wait = channel.Connect("127.0.0.1", 7777); var count = 0; while (!wait.IsDone && count++ < 3000) { Thread.Sleep(1); } try { var isThrow = false; try { channel.Send(Encoding.Default.GetBytes("helloworld")); } catch (RuntimeException) { isThrow = true; } Assert.AreEqual(true, isThrow); } finally { channel.Disconnect(); } } }
internal static bool TestHealth(string targetServer, int targetPort, int timeOutInMs, out string errMsg) { errMsg = null; NetworkChannel networkChannel = null; Exception ex = null; ExTraceGlobals.TcpChannelTracer.TraceFunction <string>(0L, "TcpHealthCheck: testing {0}", targetServer); try { ushort num = (ushort)targetPort; if (num == 0) { num = 64327; } ITcpConnector tcpConnector = Dependencies.TcpConnector; NetworkPath netPath = tcpConnector.BuildDnsNetworkPath(targetServer, (int)num); networkChannel = NetworkChannel.Connect(netPath, TcpChannel.GetDefaultTimeoutInMs(), false); TestHealthRequest testHealthRequest = new TestHealthRequest(networkChannel); testHealthRequest.Send(); NetworkChannelMessage message = networkChannel.GetMessage(); if (!(message is TestHealthReply)) { networkChannel.ThrowUnexpectedMessage(message); } ExTraceGlobals.TcpChannelTracer.TraceFunction <string>(0L, "TcpHealthCheck: {0} is healthy", targetServer); return(true); } catch (NetworkRemoteException ex2) { ex = ex2.InnerException; } catch (NetworkTransportException ex3) { ex = ex3; } catch (Win32Exception ex4) { ex = ex4; } catch (COMException ex5) { ex = ex5; } catch (ClusCommonFailException ex6) { ex = ex6; } catch (ClusCommonTransientException ex7) { ex = ex7; } finally { if (networkChannel != null) { networkChannel.Close(); } } if (ex != null) { ExTraceGlobals.TcpChannelTracer.TraceError <Exception>(0L, "TcpHealthCheck: failed: {0}", ex); errMsg = ex.Message; } return(false); }