得到Http响应

Nhu*_*yen 0 c# sockets

Socket用来获取http响应www.google.com.vn

TcpClient c = new TcpClient();
IPAddress ip = IPAddress.Parse("74.125.128.94"); // www.google.com.vn
IPEndPoint remoteEP = new IPEndPoint(ip, 80);
c.Connect(remoteEP);
StreamReader sr = new StreamReader(c.GetStream());
String s = sr.ReadToEnd();
Console.WriteLine(s);
Run Code Online (Sandbox Code Playgroud)

我没有得到任何结果.什么问题?

Jon*_*eet 6

你实际上并没有提出请求 - 你只是连接到端口.

要么向套接字写入HTTP请求,要么(最好)使用WebRequest或者WebClient不要自己最终实现HTTP客户端......