I have been given a question on an assignment which requires me to close the connection between the client and server through a client command of close. The question specifically states that the server should send a confirmation message "before the connection is closed on both side.s"

When I try to implement this I get null pointer exceptions as the server closes the connection streams after it sends the confirmation. I presume this means that when the client uses .close() the streams have already been closed, so it returns the null pointer error as those streams no longer exist.

Is this just a badly worded question, or is there some way to close a stream from the client and server at the same time. (I cannot access the socket as it's assigned to a private variable in a helper method. I also cannot use wait())

I'd be very grateful for any help or insight.