public void Handshake() { if (this.BridgeSocket == null) { TcpClient tcp = new TcpClient(this.BridgeHost, this.BridgePort); this.BridgeSocket = tcp.Client; tcp.Client = null; tcp.Close(); } NetworkStream stream = null; SamV3BridgeCommunicator bridge = null; try { stream = new NetworkStream(this.BridgeSocket); bridge = new SamV3BridgeCommunicator(stream); stream = null; string version = this.BridgeProtocolVersion; string protocolVersion = bridge.HelloVersion(version, version); if (protocolVersion != version) { throw new SamException(); } this.Bridge = bridge; bridge = null; } catch (Exception) { if (stream != null) { stream.Dispose(); } if (bridge != null) { bridge.Dispose(); } throw; } }
public void Handshake() { if (this.BridgeSocket == null) { TcpClient tcp = new TcpClient(this.BridgeHost, this.BridgePort); this.BridgeSocket = tcp.Client; tcp.Client = null; tcp.Close(); } NetworkStream stream = null; SamV3BridgeCommunicator bridge = null; try { stream = new NetworkStream(this.BridgeSocket); bridge = new SamV3BridgeCommunicator(stream); stream = null; string version = this.BridgeProtocolVersion; string protocolVersion = bridge.HelloVersion(version, version); if (protocolVersion != version) throw new SamException(); this.Bridge = bridge; bridge = null; } catch (Exception) { if (stream != null) stream.Dispose(); if (bridge != null) bridge.Dispose(); throw; } }