The following program describes how to simulate a browser to send a request to the server and output the server's return information on the console. This is what I wrote after reading what others have done, it is suitable for beginners to read java socket programs. There is also a drawback, that when connected to the Real Server, because the speed is too slow, there is no result. I don't talk much about it. There are many online programs, but they are similar. Package smallTest; import java. io. bufferedReader; import java. io. inputStream; import java. io. inputStreamReader; import java. io. outputStream; import java. io. printWriter; import java.net. socket; public class ClientDemo {/*** @ param args */public static void main (String [] args) {try {Socket s = new Socket ("127.0.0.1 ", 80); InputStream ins = s. getInputStream (); OutputStream out = s. getOutputStream (); PrintWriter pw = new PrintWriter (out, true); StringBuffer sb = new StringBuffer (); sb. append ("GET/test.htm HTTP/1.1 \ r \ n"); sb. append ("Accept: */* \ r \ n"); sb. append ("Accept-Language: zh-cn \ r \ n"); sb. append ("Host: localhost: 80 \ r \ n"); sb. append ("Connection: Keep-Alive \ r \ n"); // note, this is the key. Here, a carriage return line is required, indicating that the message header is complete, otherwise, the server will wait for sb. append ("\ r \ n"); pw. println (sb. toString (); pw. flush (); String temp; int contentLength = 200; BufferedReader br1 = new BufferedReader (new InputStreamReader (ins); for (int I = 0; I <6; I ++) do {temp = br1.readLine (); System. out. println (temp); if (temp. startsWith ("Content-Length") {contentLength = Integer. parseInt (temp. split (":") [1]. trim () ;}}while (br1.readLine () = "\ r \ n"); for (int I = 0; I <contentLength; I ++) do {temp = br1.readLine (); if (temp = null) break; System. out. println (temp);} while (br1.readLine () = "\ r \ n"); pw. close (); s. close ();} catch (Exception e) {e. printStackTrace ();}}}