JSP

HttpClient.java

본 토픽은 현재 준비중입니다.공동공부에 참여하시면 완성 되었을 때 알려드립니다.
import java.io.*;
import java.net.*;
 
class HttpClient {
public static void main(String []args) throws IOException {
   int port = (args.length >1) ? Integer.parseInt(args[1]):80;
   Socket sock = new Socket (args[0],port);
   Writer out = new OutputStreamWriter(sock.getOutputStream());
   BufferedReader stdin = new BufferedReader(new InputStreamReader(System.in));
   
   for(String line; (line=stdin.readLine()) !=null; )
      out.write(line +"\r\n");
   out.flush();
   
   InputStream in = sock.getInputStream();
   for (int ch; (ch= in.read()) != -1; )
      System.out.write(ch);
   System.out.flush();
   
   }
}
  • 봤어요 0명

댓글

댓글 본문