import java.net.*;
import java.io.*;
public class TestofWeiPu {
private static final String host = http://xxx.xxx.xxx.xx;
private static final int port = xxxx;
private static final String CONTENT_CHARSET = "GBK";
Socket socket;
public static void main(String[] args) throws Exception{
TestofWeiPu client = new TestofWeiPu();
client.createSocket();
client.LoginWeiPu();
}
public void createSocket()throws Exception{
socket = new Socket("xxx.xxx.xxx.xx",xxxx);
System.out.println ("CreateSocket");
}
public void LoginWeiPu()throws Exception{
StringBuffer sb = new StringBuffer("POST /HTTP/1.1\r\n");
sb.append("Accept:*/*\r\n");
sb.append("Referer: \r\n");
sb.append("Accept-Language: zh-cn\r\n");
sb.append("Content-Type: application/x-www-form-urlencoded\r\n");
sb.append("Accept-Encoding: gzip, deflate\r\n");
sb.append("User-Agent: Mozilla/4.0 (compatible; MSIE 7.0; Windows NT 5.1)\r\n");
sb.append("Host\r\n");
sb.append("Content-Length: 259\r\n");
sb.append("Connection: Keep-Alive\r\n");
sb.append("Pragma: no-cache\r\n");
sb.append("Cookie: \r\n\r\n");
sb.append("body");
System.out.println (sb.toString());
OutputStream socketOut = socket.getOutputStream();
System.out.println (sb.toString().getBytes().length);
socketOut.write(sb.toString().getBytes());
socketOut.flush();
BufferedReader br = new BufferedReader(new InputStreamReader(socket.getInputStream()));
String data ="null";
while(true) {
data = br.readLine();
System.out.println (data);
if(data==null)break;
}
//System.out.println ("Result:"+data);
br.close();
socket.close();
}
}