Esempio n. 1
0
 public FormSettings(Settings settings)
 {
     _settings = settings;
     InitializeComponent();
 }
Esempio n. 2
0
        /*
        public AsynchronousClient(Settings _settings)
        {
            settings = _settings;
            IsConnected = false;
        }
        */
        public void Start()
        {
            settings = new Settings();
            connectDone = new ManualResetEvent(false);
            sendDone = new ManualResetEvent(false);
            AuthDone = new ManualResetEvent(false);
            try
            {
                // Establish the remote endpoint for the socket.
                // The name of the
                IPEndPoint remoteEP = new IPEndPoint(IPAddress.Parse(settings.Host), Convert.ToInt16(settings.Port));

                // Create a TCP/IP socket.
                client = new Socket(AddressFamily.InterNetwork, SocketType.Stream, ProtocolType.Tcp);

                // Connect to the remote endpoint.
                client.BeginConnect(remoteEP, new AsyncCallback(ConnectCallback), client);
                connectDone.WaitOne();
                if (!IsConnected) { return; }

                Receive(client);

                // Send test data to the remote device.
                Send(client,"!" + settings.UserName + "@" + settings.Password);

                AuthDone.WaitOne();
            }
            catch (Exception)
            {
                //Allert.ShowMessage("Client inner Error");
                Connected("Client inner Error");
            }
        }