Example #1
0
        public void EndCheckPort(IAsyncResult ar)
        {
            AsyncState asyncState = ar.AsyncState as AsyncState;
            TcpClient  client     = asyncState.Client;
            UInt16     port       = asyncState.Port;
            bool       connected  = client.Connected;

            try
            {
                client.EndConnect(ar);

                if (_event != null)
                {
                    _event(this, new PortEventArgs(port, connected, (connected) ? "Succesfully connected!" : "Unable to connect!"));
                }
            }
            catch (Exception e)
            {
                if (_event != null)
                {
                    _event(this, new PortEventArgs(port, false, e.Message));
                }
            }
        }