System.Net.Sockets.TcpListener server = new System.Net.Sockets.TcpListener(System.Net.IPAddress.Loopback, 8080);
server.Start();
Console.WriteLine("Servidor TCP iniciado");
Console.WriteLine("Aguardando conexao de um cliente...");
TcpClient client = server.AcceptTcpClient();
Console.WriteLine("Um cliente conectou-se ao servidor");
System.IO.StreamWriter writer = new System.IO.StreamWriter(client.GetStream());
writer.Write("HTTP/1.0 200 OK\r\nContent-Type: text/plain; charset=UTF-8\r\n\r\nGoodbye, World!\r\n");
writer.Flush();
Console.WriteLine("Desligando servidor");
server.Stop();
Console.ReadKey();
当我打开浏览器并尝试访问URL http://localhost:8080 时,出现ERR_CONNECTION_RESET错误。我做错了什么?