// Constructor public MainPage() { InitializeComponent(); // create the socket Socket listenSocket = new Socket(AddressFamily.InterNetwork, SocketType.Stream, ProtocolType.Tcp); // bind the listening socket to the port IPAddress hostIP = IPAddress.Parse("127.0.0.1"); IPEndPoint ep = new IPEndPoint(hostIP, 80); listenSocket.Bind(ep); // start listening listenSocket.Listen(100); SocketAsyncEventArgs saeAccept = new SocketAsyncEventArgs(); saeAccept.Completed += saeAcceptAsyncCompleted_Completed; listenSocket.AcceptAsync(saeAccept); // this.WebBrowser.Navigate(new Uri("http://127.0.0.1", UriKind.RelativeOrAbsolute)); } int bufferOffsetReceive = 0; void saeAcceptAsyncCompleted_Completed(object sender, SocketAsyncEventArgs e) { SocketAsyncEventArgs saeReceive = new SocketAsyncEventArgs(); byte[] buff = new byte[1024]; saeReceive.SetBuffer(buff, this.bufferOffsetReceive, buff.Length); saeReceive.Completed += saeReceiveAsync_Completed; saeReceive.UserToken = e.AcceptSocket; e.AcceptSocket.ReceiveAsync(saeReceive); } void saeReceiveAsync_Completed(object sender, SocketAsyncEventArgs e) { var response = string.Format("