Connect() public method

public Connect ( IPEndPoint remoteEp ) : void
remoteEp System.Net.IPEndPoint
return void
        public override Task<bool> ConnectAsync()
        {
            if (State != ChannelStateType.Closed)
                throw new InvalidOperationException("Should be closed to connect.");

            var tcs = _connectTcs = TaskFactory.Create<bool>();
            _logger?.Info("Connect.");

            SetState(ChannelStateType.Connecting);

            var connection = new TcpConnection(_packetSerializer, _logger);
            _tcpConnection = connection;
            _tcpConnection.Connected += OnConnect;
            _tcpConnection.Received += OnReceive;
            _tcpConnection.Closed += OnClose;
            _tcpConnection.Connect(_remoteEndPoint);

            return tcs.Task;
        }
        public override Task <bool> ConnectAsync()
        {
            if (State != ChannelStateType.Closed)
            {
                throw new InvalidOperationException("Should be closed to connect.");
            }

            var tcs = _connectTcs = TaskFactory.Create <bool>();

            _logger?.Info("Connect.");

            SetState(ChannelStateType.Connecting);

            var connection = new TcpConnection(_packetSerializer, _logger);

            _tcpConnection            = connection;
            _tcpConnection.Connected += OnConnect;
            _tcpConnection.Received  += OnReceive;
            _tcpConnection.Closed    += OnClose;
            _tcpConnection.Connect(_remoteEndPoint);

            return(tcs.Task);
        }