⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 typeserver.java

📁 java threads 3th源码,包括各个章节的源代码
💻 JAVA
字号:
package javathreads.examples.ch12.example2;import java.io.*;import java.net.*;import javathreads.examples.ch12.*;public class TypeServer extends TCPThrottledServer {    public void run(Socket data) {        try {            DataOutputStream dos =                   new DataOutputStream(data.getOutputStream());            dos.writeByte(TypeServerConstants.WELCOME);            DataInputStream dis =                  new DataInputStream(data.getInputStream());            byte b = dis.readByte();            if (b != TypeServerConstants.GET_STRING_REQUEST) {                System.out.println("Client sent unknown request " + b);                return;            }            dos.writeByte(TypeServerConstants.GET_STRING_RESPONSE);            dos.writeUTF("Thisisateststring");            dos.flush();        } catch (Exception e) {            System.out.println("Client terminating: " + e);            return;        } finally {            try {                data.close();            } catch (IOException ioe) {            }        }    }    public static void main(String[] args) throws IOException {        TypeServer ts = new TypeServer();        ts.startServer(Integer.parseInt(args[0]), Integer.parseInt(args[1]));        System.out.println("Server ready and waiting...");    }}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -