internal ValueTask <ConnectionListener> ListenAsync(EndPoint endPoint, IConnectionProperties options = null, CancellationToken cancellationToken = default)
    {
        MemoryConnectionListener listener;

        if (_listeners.TryGetValue(endPoint, out _) ||
            !_listeners.TryAdd(endPoint, listener = new MemoryConnectionListener(endPoint)))
        {
            throw new IOException($"{endPoint} listener already bound");
        }

        return(new ValueTask <ConnectionListener>(listener));
    }
예제 #2
0
        public ValueTask <IConnectionListener> BindAsync(EndPoint endpoint, CancellationToken cancellationToken = default)
        {
            endpoint ??= MemoryEndPoint.Default;
            MemoryConnectionListener listener;

            if (_listeners.TryGetValue(endpoint, out _) ||
                !_listeners.TryAdd(endpoint, listener = new MemoryConnectionListener()
            {
                EndPoint = endpoint
            }))
            {
                throw new AddressInUseException($"{endpoint} listener already bound");
            }

            return(new ValueTask <IConnectionListener>(listener));
        }