1 // obtain the local Loopback: 127.0.0.1 2 IPAddress address = IPAddress. loopback; 3 // create an access endpoint. Port: 8081 4 IPEndPoint endpoint = new IPEndPoint (address, 8081 ); 5 6 // create Tcp listener 7 TcpListener tcpserver = new TcpListener (endpoint); 8 // start listening 9 tcpserver. start (); 10 Console. writeLine ("Start listening ..... "); 11 while (true) 12 {13 // wait for the customer to connect 14 TcpClient tcpClient = tcpserver. AcceptTcpClient (); 15 Console. WriteLine (" A connection has been established. "); 16 // get the Data Volume 17 NetworkStream stream = tcpClient. getStream (); 18 19 // uses UTF-8 Encoding 20 Encoding utf8 = Encoding. UTF8; 21 22 byte [] request = new byte [4096]; 23 24 int length = stream. read (requests, 0, 4096); 25 26 string requesting = utf8.GetString (request); 27 Console. writeLine (requesting); 28 29 // status line 30 string statusline = "HTTP/1.1 200 OK \ r \ n"; 31 byte [] statusBuffer = utf8.GetBytes (statusline ); 32 33 // 34 string responsestring = "