Example #1
0
        public void StartClientThread()
        {
            ClientMethods cm = new ClientMethods();
            string ipAddress = cm.GetIpAddress();
            int port = 5500;

            // Internal check
            Debug.WriteLine("Starting client thread at " + ipAddress + ":" + port + " [CLIENTCORE].");

            StartClientServer(ipAddress, port);
        }
Example #2
0
 public void ReceiveAcknowledge(string file)
 {
     ClientMethods cm = new ClientMethods();
     peerListBox.AppendText("Received " + file);
     //cm.SendUpdate(tcpServer, file, GetIpAddress());
 }
Example #3
0
        private void connStatBtn_Click(object sender, EventArgs e)
        {
            /*
            Connection status button code
            */
            // Get server IP and port number
            string servAddress = addressTextBox.Text;
            string portString = portComboBox.GetItemText(portComboBox.SelectedItem);
            int servPort = int.Parse(portString);

            Cursor.Current = Cursors.WaitCursor;
            connStatBtn.Text = "Connected";
            connStatBtn.BackColor = Color.Green;

            try
            {
                ClientMethods cm = new ClientMethods();
                cm.ServerConnect(tcpServer, servAddress, servPort);
            }
            catch (Exception error)
            {
                //errorTextBox.AppendText(DateTime.Now + "\n" + error.ToString());
                errorTextBox.AppendText(DateTime.Now + "\nSocket connection refused.");
                connStatBtn.Text = "Disconnected";
                connStatBtn.BackColor = Color.Red;
            }
        }
Example #4
0
        private void fileSearchBtn_Click(object sender, EventArgs e)
        {
            /*
            File search button code
            */
            ClientMethods cm = new ClientMethods();

            /*
            (C)lient (F)ile (R)equest
            The 'CFR' keyword is used by the server to identify that this is a request call
            made by the client form for a file hosted by another client.
            */
            String sendString = "CFR," + fileSearchBox.Text + "," + GetIpAddress();

            // Clear the textbox
            fileSearchBox.Text = "";

            cm.FileSearch(tcpServer, sendString);
        }