Socket访问网页

网页URL:[url]http://txazo.iteye.com/blog/1669205[/url]
IP地址:118.186.66.50
端口号:80

public class HttpSender {

private static byte[] request = null;

static {
StringBuffer temp = new StringBuffer();
temp.append("GET http://txazo.iteye.com/blog/1669205 HTTP/1.1\r\n"
);
temp.append("Connection: keep-alive\r\n");
temp.append("Cache-Control: max-age=0\r\n");
temp.append("\r\n");
request = temp.toString().getBytes();
}

public static void sendHttpRequest() throws Exception {
Socket socket = new Socket("118.186.66.50", 80);
OutputStream os = socket.getOutputStream();
os.write(request);
os.flush();
os.close();
socket.close();
}

}


public class HttpThread implements Runnable {

@Override
public void run() {
try {
HttpSender.sendHttpRequest();
} catch (Exception e) {
e.printStackTrace();
}
}

}


public class HttpClient {

public static void main(String[] args) throws Exception {
for (int j = 0; j < 10; j++) {
for (int i = 0; i < 20; i++) {
new Thread(new HttpThread()).start();
System.out.println(20 * j + i);
}
Thread.sleep(1000 * 10);
}
}

}

这种方法可以快速提升网站的访问量。
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值