Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

A2 - TCP Protocol Write a simple TCP program for a server that accepts lines of

ID: 3723966 • Letter: A

Question


A2 - TCP Protocol Write a simple TCP program for a server that accepts lines of input from a client and prints the lines onto the server's standard output (You can do this by modifying the TCPServer py program in the text.) Compile and execute your program. On any other machine that contains a Web browser, set the proxy server in the browser to the host that is running your server program; also configure the port number appropriately. Your browser should now send its GET request messages to your server, and your server should display the messages on its standard output. Use this platform to determine whether your browser generates conditional GET messages for objects that are locally cached ICPServer.oy.docs Submission status

Explanation / Answer

Server part:

public partial class Form1 : Form

    {

Socket sock1;

public Form1()

            {

                        InitializeComponent();

                  }

private void button1_Click(object sender, EventArgs e)

{

      string name = Dns.GetHostName();

      IPAddress ip = Dns.GetHostByName(name).AddressList[0];  

       MessageBox.Show(ip.ToString());

        IPEndPoint ipe = new IPEndPoint(ip,xxxx);

Socket sock1 =new Socket(AddressFamily.InterNetwork,SocketType.Stream,ProtocolType.Tcp);

       sock1.Bind(ipe);

        sock1.Listen(5);

        sock1 = sock1.Accept();  

          byte[] data=new byte[50000];

          sock1.Receive(data);

         textBox1.AppendText(Encoding.ASCII.GetString(data));

     }

}

}

Client part:

namespace client

{

public partial class Form1 : Form

  {

            Socket sock1;

            public Form1()

              {

                          InitializeComponent();

              }

         private void button1_Click(object sender, EventArgs e)

            {

                        string name = Dns.GetHostName();

                        IPAddress ip = Dns.GetHostByName(name).AddressList[0];  

                        IPEndPoint ipe = new IPEndPoint(ip,xxxx);

sock1 = new Socket(AddressFamily.InterNetwork,SocketType.Stream,ProtocolType.Tcp);

                        sock1.Connect(ipe);

                        MessageBox.Show("Connection Reliable.");

}

private void button2_Click(object sender, EventArgs e)

{

                          string data = textBox1.Text;

                        sock1.Send(Encoding.ASCII.GetBytes(data));

             

        }

    }

}

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote