internal ValueTask <Connection> ConnectAsync(EndPoint endPoint, IConnectionProperties options, CancellationToken cancellationToken) { if (!_listeners.TryGetValue(endPoint, out var listener) && !(endPoint is DnsEndPoint dns && _listeners.TryGetValue(new MemoryEndPoint(dns.Host), out listener))) { throw new InvalidOperationException($"{endPoint} not bound!"); } var(transport, application) = DuplexPipe.CreatePair(new PipeOptions(), new PipeOptions()); var serverConnection = Connection.FromPipe(transport, localEndPoint: endPoint, remoteEndPoint: endPoint); var clientConnection = Connection.FromPipe(application, localEndPoint: endPoint, remoteEndPoint: endPoint); listener.AcceptQueue.Writer.TryWrite(serverConnection); return(new ValueTask <Connection>(clientConnection)); }