public synchronized void close() {
        try {
            inputStream.close();
        } catch (IOException e) {
            LOGGER.warn("Can not close inputStream properly", e);
        }

        try {
            outputStream.close();
        } catch (IOException e) {
            LOGGER.warn("Can not close outputStream properly", e);
        }

        try {
            socket.close();
        } catch (IOException e) {
            LOGGER.warn("Can not close socket properly", e);
        }
    }
Wrap some of the boilerplate code using socket, enable passing around a socket together with its streams.
src/test/java/com/notnoop/apns/utils/Simulator/InputOutputSocket.java