• 大小: 3KB
    文件类型: .java
    金币: 1
    下载: 0 次
    发布日期: 2021-05-29
  • 语言: Java
  • 标签: ssd8  exam1  答案  java  

资源简介

卡耐基ssd8的exam1的答案,绝对能运行,能拿满分!有较多的注释,读起来较容易懂,为学ssd的同学减轻负担

资源截图

代码片段和文件信息

 import java.io.*;
import java.net.*;
//java。lang。是默认导入的。
import java.lang.*;
public class ProxyServer {
    private static int PORT = 8000;
    static private String CRLF = “\r\n“;

    
    static class  Handler implements Runnable {
        private Socket socket;
           DataOutputStream OutToClient;
        BufferedReader InFromClient;
        DataOutputStream OutToServer;
        DataInputStream InFromServer;
        
        public Handler(Socket s) {
            Thread t;
            socket = s;
            t = new Thread(this “Handler Thread“);
            t.start();
        }
        
        public void run() {
            try {
                OutToClient = new DataOutputStream(socket.getOutputStream());
                InFromClient = new BufferedReader(new InputStreamReader(socket.getInputStream()));
                String getString = InFromClient.readLine();
                System.out.print(getString+‘\n‘);
                String[] checkString = getString.split(“ “);
                String url;
                Socket linkServer;
    
                int urlPort;
                if(checkString[0].equalsIgnoreCase(“GET“) ){
                    linkServer = linkToServer(checkString[1]);
                }else{
                    System.out.println(“invalid input!\n“);
                    throw new IOException(“invalid input!\n“);
                }
                
                
                
                OutToServer = new DataOutputStream(linkServer.getOutputStream());
          

评论

共有 条评论