protected Socket getSocket()
protected synchronized Socket getSocket()
  protected Socket getSocket()    throws IOException  {    if (socket == null)      {        String connectHostname = hostname;        int connectPort = port;        if (isUsingProxy())          {            connectHostname = proxyHostname;            connectPort = proxyPort;          }        socket = new Socket();        InetSocketAddress address =          new InetSocketAddress(connectHostname, connectPort);        if (connectionTimeout > 0)          {            socket.connect(address, connectionTimeout);          }        else          {            socket.connect(address);          }        if (timeout > 0)          {            socket.setSoTimeout(timeout);          }        if (secure)          {            try              {                SSLSocketFactory factory = getSSLSocketFactory();                SSLSocket ss =                  (SSLSocket) factory.createSocket(socket, connectHostname,                                                   connectPort, true);                String[] protocols = { "TLSv1", "SSLv3" };                ss.setEnabledProtocols(protocols);                ss.setUseClientMode(true);                synchronized (handshakeCompletedListeners)                  {                    if (!handshakeCompletedListeners.isEmpty())                      {                        for (Iterator i =                             handshakeCompletedListeners.iterator();                             i.hasNext(); )                          {                            HandshakeCompletedListener l =                              (HandshakeCompletedListener) i.next();                            ss.addHandshakeCompletedListener(l);                          }                      }                  }                ss.startHandshake();                socket = ss;              }            catch (GeneralSecurityException e)              {                throw new IOException(e.getMessage());              }          }        in = socket.getInputStream();        in = new BufferedInputStream(in);        out = socket.getOutputStream();        out = new BufferedOutputStream(out);      }    return socket;  }