public synchronized void reconnect() throws UnknownHostException, IOException, HttpException,
                    UnsupportedAuthenticationException, AuthenticationCancelledException {
        close();
        if (!client.isProxyConfigured()) {
            // #ifdef DEBUG
            log.debug(MessageFormat.format(Messages.getString("HttpConnection.connectingTo"), new Object[] { client.hostname, new Integer(client.port) })); //$NON-NLS-1$
            // #endif
            this.socket = SocketWithLayeredTransportFactory.getDefault().createSocket(client.hostname, client.port);
            this.socket.setTcpNoDelay(noDelay);
            
            // LDP - Always push a transport even if its null. This allows us to pick up
            // a start event in child implementations of the socket so we can decide
            // when to start streaming across forwarded sockets that may or may not
            // require an SSL transport.
            this.socket.pushTransport(client.isSecure ? SSLTransportFactory.newInstance() : null);
            
        } else {

            synchronized (client) {
                switch (client.proxyType) {
                    case HttpClient.PROXY_HTTP:
                    case HttpClient.PROXY_HTTPS:

                        // #ifdef DEBUG
                        log.debug(MessageFormat.format(Messages.getString("HttpConnection.proxyConnect"), new Object[] { client.hostname, new Integer(client.port), client.proxyType == HttpClient.PROXY_HTTPS ? "https" : "http", client.proxyHost, new Integer(client.proxyPort) })); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
                        // #endif
                        // Setup the proxy client connection
                        if (client.proxyClient == null) {
                            client.proxyClient = new HttpClient(client);
                        }

                        ConnectMethod proxyConnect = new ConnectMethod(client.hostname, client.port, client.isSecure);
                        // Execute and retreive the direct socket
                        HttpResponse response = client.proxyClient.execute(proxyConnect);

                        if (response.getStatus() == 200) {
                            socket = response.getConnection().socket;
                        } else
                            throw new IOException(MessageFormat.format(Messages.getString("HttpConnection.invalidHttpStatusCode"), new Object[] { new Integer(response.getStatus()) })); //$NON-NLS-1$
                        break;
                    default:
                        throw new IllegalArgumentException(MessageFormat.format(Messages.getString("HttpConnection.invalidProxyType"), new Object[] { new Integer(client.proxyType) })); //$NON-NLS-1$
                }
            }
        }

        int lingerTime = socket.getSoLinger();
        socket.setSoLinger(linger, false ? 0 : (lingerTime == -1 ? 0 : lingerTime));

        in = new HttpConnectionInputStream(socket.getInputStream(), 32768);
        out = new HttpConnectionOutputStream();
System.out.println(out.toString());
        isClosed = false;
        canReuse = true;
    }