I wrote this code
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);
Server code
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();
I want to send a number to the Server, increment it and send it again to the client. The first part work fine, i send the number to the server and he can read it, but in the second part i have a NullPointerError, i don't really know where