RPC远程通信

    技术2022-07-10  177

    //创建套接字,默认本地IP new' ServerSocket(8080) //连接后,会阻塞 Socket socket=serverSocket.accept() (read/write阻塞) BufferReader buffer=new BufferReader(new inputStreamReader(socket.getInputStream))); buffer.readLine();

    客户端

    //创建套接字,默认本地IP //连接 Socket socket=new Socket("localhost" ,8080); PrintWriter out =new PrintWriter(socket.getOutPutStream(),true) out.println("111");

    BIO模型

    连接阻塞

    accept()

    IO阻塞 BufferReader buffer=new BufferReader(new inputStreamReader(socket.getInputStream)));

    非阻塞

    Netty

    Processed: 0.044, SQL: 9