Exemple #1
0
        private void startReceivingButton_Click(object sender, EventArgs e)
        {
            ushort tcpPort = (ushort)this.portNumberSelector.Value;
            bool   useSsl  = this.useSslCheckBox.Checked;


            //this.textBox1.AppendText("Listening to TCP " + tcpPort + "\n");
            this.UpdateGui();
            try {
                this.pcapTcpStream = new PcapTcpStream(tcpPort, useSsl, (int)this.timoutSelector.Value * 1000);
                this.pcapTcpStream.BeginAcceptTcpClient(this.StreamEstablishedHandler);
                this.UpdateGui();
            }
            catch (System.Net.Sockets.SocketException sockEx) {
                MessageBox.Show("Unable to open socket, try another port number!\n\n" + sockEx.Message, "Socket Exception");
            }
        }
        private void startReceivingButton_Click(object sender, EventArgs e)
        {
            bool useSsl = this.useSslCheckBox.Checked;
            int  idleTimeoutMilliSeconds = (int)this.timoutSelector.Value * 1000;

            if (this.incomingTcpRadioButton.Checked)
            {
                ushort tcpPort = (ushort)this.portNumberSelectorIncoming.Value;
                this.UpdateGui();
                try {
                    this.pcapTcpStream = new PcapTcpStream(tcpPort, useSsl, idleTimeoutMilliSeconds);
                    this.pcapTcpStream.BeginAcceptTcpClient(this.StreamEstablishedHandler);
                    this.UpdateGui();
                }
                catch (System.Net.Sockets.SocketException sockEx) {
                    MessageBox.Show("Unable to open socket, try another port number!\n\n" + sockEx.Message, "Socket Exception");
                }
            }
            else if (this.outgoingTcpRadioButton.Checked)
            {
                ushort tcpPort = (ushort)this.portNumberSelectorOutgoing.Value;
                try {
                    this.pcapTcpStream = new PcapTcpStream(this.ipTextBoxOutgoing.Text, tcpPort, useSsl, idleTimeoutMilliSeconds, this.StreamEstablishedHandler);
                    this.UpdateGui();
                    if (this.pcapTcpStream != null && this.pcapTcpStream.PcapStream != null)
                    {
                        this.StreamEstablishedHandler();
                    }
                }
                catch (System.Net.Sockets.SocketException) {
                }
            }
            else
            {
                throw new Exception("Select either the incoming or outgoing radio button!");
            }
        }