Exemple #1
0
        private void Button2_Click(object sender, EventArgs e)
        {
            try
            {
                server = new AsyncSocketServer(IPAddress.Parse(IPcomboBox.Text), int.Parse(PorttextBox.Text), 10);
                server._ServerStart        += TcpServerStar;
                server._ClientConnected    += ClientConnected;
                server._ClientDisconnected += ClientDisconnected;
                server._ReceiveData        += ReceiveData;
                server._SendData           += SendData;
                server.ServerStart();

                button2.Enabled     = !server.IsRunning;
                button1.Enabled     = server.IsRunning;
                IPcomboBox.Enabled  = !server.IsRunning;
                PorttextBox.Enabled = !server.IsRunning;
            }
            catch
            {
                server?.Dispose();
                button2.Enabled     = true;
                button1.Enabled     = false;
                IPcomboBox.Enabled  = true;
                PorttextBox.Enabled = true;
            }
        }
Exemple #2
0
        private void Button1_Click(object sender, EventArgs e)
        {
            server._ServerStart        -= TcpServerStar;
            server._ClientConnected    -= ClientConnected;
            server._ClientDisconnected -= ClientDisconnected;
            server._ReceiveData        -= ReceiveData;
            server._SendData           -= SendData;
            server?.Dispose();

            button2.Enabled     = true;
            button1.Enabled     = false;
            IPcomboBox.Enabled  = true;
            PorttextBox.Enabled = true;
        }