code: public void setSocket(Socket socket) throws IOException {
          if (this.socket != null) {
              this.socket.close();
              this.socket = null;
          }
          this.socket = socket;
          setTimeout(timeout);
          prepareStreams(socket);
      }
docs: Sets the <tt>Socket</tt> used for message transport and prepares the
  streams used for the actual I/O.
  
  @param socket the <tt>Socket</tt> used for message transport.
  
  @throws IOException if an I/O related error occurs.