When I send only one object through a socket i am ok. But when i am trying to send two objects, i get
Exception in thread "main" java.net.SocketException: Connection reset
at java.net.SocketInputStream.read(Unknown Source))
I have tried almost everything like flush() or reset() but none of them work.
public String SendObject(Object o) throws IOException {
    OutputStream outToServer = client.getOutputStream();
    ObjectOutputStream out = new ObjectOutputStream(outToServer);
    out.writeUnshared(o);
    InputStream inFromServer = client.getInputStream();
    DataInputStream in = new DataInputStream(inFromServer);
    return in.readUTF();
}
				
                        
You're using an
ObjectOutputStreamto write theObject(s) from the client. You should be using anObjectInputStream(not aDataInputStream) to read them on the server. To read twoObjects might look something like,Also, on the client, I think you wanted
writeObject(instead ofwriteUnshared) like