     internal let socket: T
     private let closePromise: EventLoopPromise<Void>
     private let selectableEventLoop: SelectableEventLoop
-    private let localAddressCached: AtomicBox<Box<SocketAddress?>> = AtomicBox(value: Box(nil))
-    private let remoteAddressCached: AtomicBox<Box<SocketAddress?>> = AtomicBox(value: Box(nil))
+    private let addressesCached: AtomicBox<Box<(local:SocketAddress?, remote:SocketAddress?)>> = AtomicBox(value: Box((local: nil, remote: nil)))
     private let bufferAllocatorCached: AtomicBox<Box<ByteBufferAllocator>>
 
     internal var interestedEvent: IOEvent = .none

        self.recvAllocator = recvAllocator
        self._pipeline = ChannelPipeline(channel: self)
        // As the socket may already be connected we should ensure we start with the correct addresses cached.
        self.localAddressCached.store(Box(try? socket.localAddress()))
        self.remoteAddressCached.store(Box(try? socket.remoteAddress()))
    }

    deinit {


    internal final func updateCachedAddressesFromSocket(updateLocal: Bool = true, updateRemote: Bool = true) {
        assert(self.eventLoop.inEventLoop)
        assert(updateLocal || updateRemote)
        let cached = addressesCached.load().value
        let local = updateLocal ? try? self.localAddress0() : cached.local
        let remote = updateRemote ? try? self.remoteAddress0() : cached.remote
        self.addressesCached.store(Box((local: local, remote: remote)))
    }

    internal final func unsetCachedAddressesFromSocket() {
        assert(self.eventLoop.inEventLoop)
        self.addressesCached.store(Box((local: nil, remote: nil)))
    }

    public final func connect0(to address: SocketAddress, promise: EventLoopPromise<Void>?) {
