@Test ( timeout = 2000 )
    public void clientWriteToSocketClosedByClient () throws Exception {
        Socket[] sockets = connectToServer();
        try ( Socket serverSocket = sockets[ 0 ];
              Socket clientSocket = sockets[ 1 ] ) {

            clientSocket.close();
            // wait for close to propagate
            Thread.sleep(100);

            IOException exception = null;
            try {
                clientSocket.getOutputStream().write(new byte[] {
                    '1'
                });
            }
            catch ( IOException e ) {
                exception = e;
            }

            assertNotNull("Client should see an IOException when writing to a socket which it closed.", exception);

        }
    }