我写了这段代码
Random rand = new Random();
int n = rand.nextInt(50) + 1;
DataOutputStream dos = new DataOutputStream(_socket.getOutputStream());
dos.writeInt(n);
dos.flush();
DataInputStream in = new DataInputStream(_socket.getInputStream());
int ServerNumber= in.readInt();
System.out.println(ServerNumber);
服务器代码
DataInputStream in = new DataInputStream(socket.getInputStream());
int ClientNumber= in.readInt();
System.out.println(ClientNumber);
System.out.println("----tessst----");
ClientNumber++;
DataOutputStream dos = new DataOutputStream(socket.getOutputStream());
dos.writeInt(ClientNumber);
dos.flush();
我想向服务器发送一个号码,递增它并再次发送给客户端。第一部分工作正常,我将数字发送到服务器,他可以读取它,但在第二部分我有一个NullPointerError,我真的不知道在哪里