Auxilium.Classes.Client.Connect C# (CSharp) Method

Connect() public method

public Connect ( string host, ushort port ) : void
host string
port ushort
return void
        public void Connect(string host, ushort port)
        {
            try
            {
                Disconnect();
                Initialize();

                _handle = new Socket(AddressFamily.InterNetwork, SocketType.Stream, ProtocolType.Tcp);

                _handle.SetSocketOption(SocketOptionLevel.Socket, SocketOptionName.KeepAlive, true);
                _handle.SetSocketOption(SocketOptionLevel.Socket, SocketOptionName.NoDelay, true);
                _handle.NoDelay = true;

                _items[0].RemoteEndPoint = new IPEndPoint(IPAddress.Parse(host), port);
                if (!_handle.ConnectAsync(_items[0]))
                    Process(null, _items[0]);
            }
            catch (Exception ex)
            {
                Console.WriteLine(ex.ToString());
                OnClientFail();
                Disconnect();
            }
        }