Change InputOutputSocket to synchronize write() and close().