ImageIO.write(image, "png", socket.getInputStream);
This is the only way I tried, and it does work but it needs the outputStream to be closed or I can't save the image.
My problem is that I need the connection to be alive even after the sending, so I read on the internet that i have to convert a BufferedImage in byte[] and viceversa in the client and in the server.
How do I do that?