socket模拟http请求
来源:互联网 发布:留学新加坡 知乎 编辑:程序博客网 时间:2024/05/21 07:55
public static void main(String[] args) { try { Socket socket = new Socket("220.181.111.86",80); PrintWriter printWriter = new PrintWriter(new OutputStreamWriter(socket.getOutputStream())); printWriter.println("GET / HTTP/1.1"); //方式 根目录 协议 printWriter.println("Host:www.baidu.com"); //host printWriter.println("Content-Type:text/html"); printWriter.println(); printWriter.flush(); BufferedReader bufferedReader=new BufferedReader(new InputStreamReader(socket.getInputStream())); String str=null; while ((str=bufferedReader.readLine())!=null){ System.out.println(str); } bufferedReader.close(); printWriter.close(); socket.close(); } catch (Exception e) { e.printStackTrace(); //To change body of catch statement use File | Settings | File Templates. } }1.先在dos下ping www.baidu.com 拿到ip
2.注意
printWriter.println(); printWriter.flush();
0 0
- socket模拟http请求
- socket模拟http请求
- socket模拟http请求
- 利用Socket模拟http请求
- 使用socket模拟Http请求
- socket模拟http发送请求
- PHP SOCKET模拟HTTP请求
- java socket模拟http请求
- linux socket模拟HTTP请求上传数据
- php利用socket函数模拟发送http请求
- php利用socket函数模拟发送http请求
- php利用socket函数模拟发送http请求
- php利用socket函数模拟发送http请求
- python socket模拟一个http Get请求页面
- 继续研究socket模拟浏览器发送http请求 大家帮忙
- Socket模拟GET请求
- Socket模拟Http协议
- c++ socket 模拟 http
- IOS7新特性汇总
- STL中队列的使用
- 关于使用 ASIHTTPRequest URL中文参数乱码问题
- 让Box2D刚体无阻尼匀速运动
- 我的spfa (= =)!
- socket模拟http请求
- 利用深度优先搜索做的随机生成地图的迷宫小游戏
- python 去除html标签函数
- squashfs make
- 使用笔记本分享热点点击命令出现,“netsh”不是内部或外部命令,也不是可运行的程序或批处理文件解决办法
- iOS中常用的四种数据持久化方法简介
- poj 1901 跳蚤 扩展欧几里得定理和容斥原理的应用
- 进程组,会话,控制终端,守护进程(请大家指教)
- C/C++内存分配知识