Ejemplo n.º 1
0
        public C_LED_Control(String Host, String LEDCODE, int Port, int Duration)
        {
            this._host     = Host;
            this._ledcode  = LEDCODE;
            this._port     = Port;
            this._duration = Duration;

            if (this._duration < 0)
            {
                //Wenn die Dauer negativ ist, sollen die LEDs nicht wieder abgeschaltet werden.
                //Wir benötigen daher ein Empfangs-OK weniger vom Server
                this._okshouldbe = this._okshouldbe - 1;
            }


            this.tcpclient = new Co0nUtilZ.C_NetClient(this._host, this._port);
            //this.tcpclient = new TorLED.C_NetClient(this._host, this._port);
            this.tcpclient.ConnectTimeout = 1300; //Maximal x Millisekunden versuchen eine Verbindung aufzubauen.

            //Events abbonieren
            this.tcpclient.Connected    += this.Handle_Connected;
            this.tcpclient.Disconnected += this.Handle_Disconnected;
            this.tcpclient.DataReceived += this.Handle_DataReceived;
            this.tcpclient.DataSent     += this.Handle_DataSent;
            this.tcpclient.OnError      += this.Handle_ErrorOccured;
        }
Ejemplo n.º 2
0
 private void btnConnect_Click(object sender, EventArgs e)
 {
     try
     {
         this.TCPConnection               = new Co0nUtilZ.C_NetClient(this.txtHost.Text, int.Parse(this.txtPort.Text));
         this.TCPConnection.Connected    += this.Handle_Connected;
         this.TCPConnection.Disconnected += this.Handle_Disconnected;
         this.TCPConnection.DataReceived += this.Handle_DataReceived;
         this.TCPConnection.DataSent     += this.Handle_DataSent;
         this.TCPConnection.OnError      += this.Handle_ErrorOccured;
         this.TCPConnection.ConnectToServer();
     }
     catch (Exception ex)
     {
         MessageBox.Show("Fehler beim Verbinden. Bitte prüfen Sie die angegebenen Daten.\r\n\r\n" + ex.ToString(), "Fehler,", MessageBoxButtons.OK, MessageBoxIcon.Warning);
     }
 }