public void Open() { lock (this.ThisLock) { this.addressChangeHelper = new AddressChangeHelper(new AddressChangeHelper.AddedChangedCallback(this.OnAddressChanged)); this.localAddresses = this.GetAddresses(); if (Socket.OSSupportsIPv6) { this.ipv6Socket = new Socket(AddressFamily.InterNetworkV6, SocketType.Stream, ProtocolType.IP); } this.isOpen = true; } }
public void Open() { lock (ThisLock) { Fx.Assert(!this.isOpen, "Helper not expected to be open"); // Register for addr changed event and retrieve addresses from the system this.addressChangeHelper = new AddressChangeHelper(OnAddressChanged); this.localAddresses = GetAddresses(); if (Socket.OSSupportsIPv6) { this.ipv6Socket = new Socket(AddressFamily.InterNetworkV6, SocketType.Stream, ProtocolType.IP); } this.isOpen = true; } }
public void Close() { if (this.isOpen) { lock (this.ThisLock) { if (this.isOpen) { this.addressChangeHelper.Unregister(); if (this.ipv6Socket != null) { this.ipv6Socket.Close(); } this.isOpen = false; this.addressChangeHelper = null; } } } }