Akka.Interfaced.SlimSocket.Client.TcpConnection.Connect C# (CSharp) Method

Connect() public method

public Connect ( IPEndPoint remoteEp ) : void
remoteEp System.Net.IPEndPoint
return void
        public void Connect(IPEndPoint remoteEp)
        {
            if (_state != TcpState.Closed)
            {
                throw new Exception("Closed Only");
            }

            _state = TcpState.Connecting;
            _localEndPoint = null;
            _remoteEndPoint = remoteEp;

            _client = new TcpClient();
            _client.BeginConnect(remoteEp.Address, remoteEp.Port, ConnectCallback, null);
        }

Usage Example

        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;
        }
All Usage Examples Of Akka.Interfaced.SlimSocket.Client.TcpConnection::Connect