コード例 #1
0
        private void button1_Click(object sender, EventArgs e)
        {
            clientSock = new Socket(AddressFamily.InterNetwork, SocketType.Stream, ProtocolType.Tcp);
            byte[] form_name     = Encoding.UTF8.GetBytes(this.Text);
            byte[] username      = Encoding.UTF8.GetBytes(textBox1.Text);
            byte[] password      = Encoding.UTF8.GetBytes(textBox2.Text);
            byte[] form_name_len = BitConverter.GetBytes(form_name.Length);
            byte[] userNameLen   = BitConverter.GetBytes(username.Length);
            byte[] passwordLen   = BitConverter.GetBytes(password.Length);
            a = new byte[12 + form_name.Length + username.Length + password.Length];
            form_name_len.CopyTo(a, 0);
            form_name.CopyTo(a, 4);
            userNameLen.CopyTo(a, 4 + form_name.Length);
            username.CopyTo(a, 8 + form_name.Length);
            passwordLen.CopyTo(a, 8 + form_name.Length + username.Length);
            password.CopyTo(a, 12 + form_name.Length + username.Length);
            clientSock.Connect(s, 8888); //target machine's ip address and the port number
            clientSock.Send(a);
            byte[] b   = new byte[1024];
            string str = Encoding.ASCII.GetString(b, 0, clientSock.Receive(b));

            MessageBox.Show(str);
            clientSock.Close();
            transfer t = new transfer(s);

            t.Show();
            this.Close();
        }
コード例 #2
0
        private void linkLabel1_LinkClicked(object sender, LinkLabelLinkClickedEventArgs e)
        {
            this.Close();
            transfer t = new transfer("127.0.0.1");

            t.Show();
        }
コード例 #3
0
        private void linkLabel1_LinkClicked(object sender, LinkLabelLinkClickedEventArgs e)
        {
            clientSock.Close();
            transfer t = new transfer("192.168.0.1");

            t.Show();
            this.Close();
        }
コード例 #4
0
 private void sendButton_Click_1(object sender, EventArgs e)
 {
     if (textBox2.Text == null)
     {
         MessageBox.Show("Username cannot be null");
     }
     else if (textBox3.Text == null)
     {
         MessageBox.Show("Password Cannot be null");
     }
     else if (textBox1.Text == null)
     {
         MessageBox.Show("Browse a valid folder");
     }
     else
     {
         str1       = textBox1.Text;
         clientSock = new Socket(AddressFamily.InterNetwork, SocketType.Stream, ProtocolType.Tcp);
         byte[] form_name     = Encoding.UTF8.GetBytes(this.Text);
         byte[] text          = Encoding.UTF8.GetBytes(textBox1.Text);
         byte[] username      = Encoding.UTF8.GetBytes(textBox2.Text);
         byte[] password      = Encoding.UTF8.GetBytes(textBox3.Text);
         byte[] form_name_len = BitConverter.GetBytes(form_name.Length);
         byte[] fileNameLen   = BitConverter.GetBytes(text.Length); //lenght of text
         byte[] userNameLen   = BitConverter.GetBytes(username.Length);
         byte[] passwordLen   = BitConverter.GetBytes(password.Length);
         a = new byte[16 + form_name.Length + text.Length + username.Length + password.Length];
         form_name_len.CopyTo(a, 0);
         form_name.CopyTo(a, 4);
         userNameLen.CopyTo(a, 4 + form_name.Length);
         username.CopyTo(a, 8 + form_name.Length);
         passwordLen.CopyTo(a, 8 + form_name.Length + username.Length);
         password.CopyTo(a, 12 + form_name.Length + username.Length);
         fileNameLen.CopyTo(a, 12 + form_name.Length + username.Length + password.Length);
         text.CopyTo(a, 16 + form_name.Length + username.Length + password.Length);
         clientSock.Connect(s, 8888); //target machine's ip address and the port number
         clientSock.Send(a);
         byte[] b   = new byte[1024];
         string str = Encoding.ASCII.GetString(b, 0, clientSock.Receive(b));
         MessageBox.Show(str);
         clientSock.Close();
         transfer t = new transfer(s);
         t.Show();
         this.Close();
     }
 }
コード例 #5
0
        private void button2_Click(object sender, EventArgs e)
        {
            transfer f = new transfer("192.168.0.1");

            f.Show();
        }