MCPcopy Create free account
hub / github.com/Ramos-dev/OSSTunnel / AcceptThread

Class AcceptThread

client/src/test/java/A.java:21–77  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

19 }
20
21 static class AcceptThread extends Thread {
22
23 ServerSocket serverSocket;
24
25 {
26 try {
27 serverSocket = new ServerSocket(port);
28 System.out.println(port);
29 } catch (IOException e) {
30 e.printStackTrace();
31 }
32 }
33
34 public void run() {
35
36 Socket socket = null;
37 DataInputStream input = null;
38
39 try {
40 socket = serverSocket.accept();
41 socket.setKeepAlive(true);
42
43 while (true) {
44 input = new DataInputStream(socket.getInputStream());
45 byte[] buffer = {};
46 int bufflenth = input.available();
47 int size = 0;
48 while (bufflenth != 0) {
49 // 初始化byte数组为buffer中数据的长度
50 buffer = new byte[bufflenth];
51 size += input.read(buffer);
52 bufflenth = input.available();
53 }
54 if (buffer.length != 0) {
55
56 }
57
58 }
59 } catch (Exception e) {
60 e.printStackTrace();
61 } finally {
62 try {
63 if (input != null) {
64 input.close();
65 input = null;
66 }
67 if (socket != null) {
68 socket.close();
69 socket = null;
70 }
71 } catch (IOException e) {
72 // TODO Auto-generated catch block
73 e.printStackTrace();
74 }
75 }
76 }
77 }
78}

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected