| 4 | import java.net.Socket; |
| 5 | |
| 6 | public class A { |
| 7 | |
| 8 | static int port = 1; |
| 9 | |
| 10 | public static void main(String[] args) { |
| 11 | |
| 12 | for (int i = 1; i < 65534; i++) { |
| 13 | new A.AcceptThread().start(); |
| 14 | |
| 15 | port++; |
| 16 | } |
| 17 | |
| 18 | |
| 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) { |
nothing calls this directly
no outgoing calls
no test coverage detected