this is my Client code
Random rand = new Random(); int n = rand.nextInt(50) + 1; DataInputStream dis = new DataInputStream(_socket.getInputStream()); DataOutput
If you're using writeInt() on the write side, you should be using readInt() on the read side (all the method names correlate between DataOutputStream and DataInputStream, please read the javadoc).
writeInt()
readInt()