请教:一个简单的网络问题
在win2000命令行窗口中执行
telnet www.sina.com.cn(回车)
get/http/1.0(两个回车)
得到如下的信息回馈:
HTTP/1.0 400 Bad Request
Server: squid/2.5.STABLE5
Mime-Version: 1.0
Date: Wed, 08 Dec 2004 08:10:05 GMT
Content-Type: text/html
Content-Length: 1196
Expires: Wed, 08 Dec 2004 08:10:05 GMT
X-Squid-Error: ERR_INVALID_REQ 0
X-Cache: MISS from autoinstall.sina.com.cn
Proxy-Connection: close
。。。。。。。。。。。。。。
现在想编一个程序实现同样的功能,怎么实现,下面的程序有什么不对?请高手指点
import java.io.*;
import java.net.*;
public class nettest1
{
public static void main(String[] args)
{
String command="get/http/1.0\r\n\r\n";
try
{
Socket t=new Socket("10.204.6.35",80);
PrintWriter out=new PrintWriter(t.getOutputStream(),true);
out.print(command);
DataInputStream is=new DataInputStream(t.getInputStream());
boolean more=true;
while(more)
{
String str=is.readLine();
if(str==null)
more=false;
else
System.out.println(str);
}
t.close();
}
catch(IOException e)
{
System.out.println("Error"+e);
}
}
}