当前位置:首页 » 文件传输 » java访问服务器端口
扩展阅读
webinf下怎么引入js 2023-08-31 21:54:13
堡垒机怎么打开web 2023-08-31 21:54:11

java访问服务器端口

发布时间: 2023-04-15 20:36:06

⑴ 怎样通过java使用socks代理访问服务器

packagetest;

importjava.io.IOException;
importjava.util.Date;

importorg.apache.commons.httpclient.HttpClient;
importorg.apache.commons.httpclient.HttpException;
importorg.apache.commons.httpclient.UsernamePasswordCredentials;
importorg.apache.commons.httpclient.auth.AuthScope;
importorg.apache.commons.httpclient.methods.PostMethod;

publicclasstest
{
publicstaticvoidmain(Stringargs[])
{
HttpClienthc=newHttpClient();

System.out.println("开始时间:"+System.currentTimeMillis());
for(inti=0;i<=100;i++)
{

try
{
//每10秒才会保存一次
Thread.sleep(12000);
}catch(InterruptedExceptione1)
{
//TODOAuto-generatedcatchblock
e1.printStackTrace();
}
Dated=newDate();
PostMethodpm=newPostMethod(
"http://www.tongaichina.com/post.asp?type=int&name=click&time="
+d.getTime());
try
{

//这里写代理地址及端口
hc.getHostConfiguration().setProxy("代理地址",端口);

//这里是用户名与密码
=(
"用户名","密码");
hc.getState().setProxyCredentials(AuthScope.ANY,creds);

hc.executeMethod(pm);
System.out.println(pm.getResponseBodyAsString());
}catch(HttpExceptione)
{
//TODOAuto-generatedcatchblock
e.printStackTrace();
}catch(IOExceptione)
{
//TODOAuto-generatedcatchblock
e.printStackTrace();
}
System.out.println(i);
}
System.out.println("结束时间:"+System.currentTimeMillis());
}
}