Пример #1
0
        public Client()
        {
            InitializeComponent();
            lbChat.Items.Add("Bitte Chat Namen eingeben.");

            AsyClient = new AsyncTcpClient();

            AsyClient.PacketReceived += AsyClient_PacketReceived;
        }
        public static void Connect(TextBox txtip, TextBox txtport)
        {
            client = new AsyncTcpClient();
            IPAddress address = IPAddress.Parse(txtip.Text);


            try
            {
                client.Connect(address, Convert.ToInt16(txtport.Text));
            }
            catch (Exception)
            {
                MessageBox.Show("Fehler beim verbinden mit dem Server.", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }
        public frmClient()
        {
            InitializeComponent();

            client = new AsyncTcpClient();
            client.PacketReceived += Client_PacketReceived;

            CPUwork      = new TimeChart(ctCPU, "CPU", 20);
            RAMav        = new TimeChart(ctRAM, "RAM available", 20);
            DiskWorkload = new TimeChart(ctDiskWork, "Disk Workload", 20);
            DiskR        = new TimeChart(ctDiskR, "Read", 20);
            DiskW        = new TimeChart(ctDiskW, "Write", 20);

            this.Width  = 535;
            this.Height = 230;

            cpbRAM.SendToBack();
            cpbCPU.SendToBack();
            cpbNetwork.SendToBack();
            cpbDisk.SendToBack();

            txtIP.Text   = Properties.Settings.Default.IP;
            txtPort.Text = Properties.Settings.Default.Port.ToString();
        }
Пример #4
0
        static void Main(string[] args)
        {
            AsyncTcpClient client = SocketFactory.CreateClient <AsyncTcpClient>("127.0.0.1", 9090);

            client.DataReceive = (o, e) =>
            {
                var pipestream = e.Stream.ToPipeStream();
                if (pipestream.TryReadLine(out string line))
                {
                    Console.WriteLine(line);
                }
            };
            while (true)
            {
                Console.Write("Enter Name:");
                BytesHandler line = Console.ReadLine() + "\r\n";
                client.Send(line);
                if (!client.IsConnected)
                {
                    Console.WriteLine(client.LastError.Message);
                }
            }
        }
    }