import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.net.Socket;
import java.net.UnknownHostException;
public class IeClient {
public static void main(String[]args) throws UnknownHostException, IOException{
Socket s=new Socket("192.168.1.100",8080);
PrintWriter out=new PrintWriter(s.getOutputStream(),true);
out.println("GET /index.html http/1.1");
out.println("Accept: */*");
out.println("Accept-Encoding: gzip, deflate");
out.println("User-Agent: Mozilla/5.0 (compatible; MSIE 9.0; Windows NT 6.1; Trident/5.0)");
out.println("Host: 192.168.1.100:8080");
out.println("Connection: close");
out.println();
out.println();
InputStream is=s.getInputStream();
byte[]buf=new byte[1024];
int len=is.read(buf);
String text=new String(buf,0,len);
System.out.println(text);
s.close();
}
}
控制台显示:
HTTP/1.1 505 HTTP Version Not Supported
Server: Apache-Coyote/1.1
Date: Mon, 01 Jul 2013 14:43:42 GMT
Connection: close
接收不到服务器发来的请求资源,这是什么问题造成的? |
|