Results 1 to 2 of 2

Thread: QTcpsocket - connection problem

  1. #1
    Join Date
    Jan 2007
    Location
    Chennai, India
    Posts
    25
    Thanks
    1
    Qt products
    Qt3 Qt4
    Platforms
    Windows

    Default QTcpsocket - connection problem

    I have code like this to connect my server.

    m_socket = new QTcpSocket();

    connect( (QObject * ) m_socket, SIGNAL( proxyAuthenticationRequired ( const QNetworkProxy &, QAuthenticator *) ),this, SLOT( proxyAuthenticationRequiredFunction (

    const QNetworkProxy &, QAuthenticator * ) ));

    /*! To connect the server */
    void ACMClient::connectToServer()
    //************************************************** ****
    {
    m_networkProxy.setHostName("xx.xx.xx.xx");
    m_networkProxy.setPort(3128);
    m_networkProxy.setUser("username");
    m_networkProxy.setPassword("password");
    m_networkProxy.setType(QNetworkProxy::HttpProxy);
    m_socket->setProxy(m_networkProxy);

    m_socket->connectToHost("xx.xx.xx.xx",3456,QIODevice::ReadW rite);
    }



    proxyAuthenticationRequired signal is not emitted when i am tring to connect the server with proxy settings and i got the below error

    QAbstractSocket::HostLookupState
    QAbstractSocket::ConnectingState

    UNEXPECTED RESPONSE: [HTTP/-1163005939.-1163005939 -1163005939

    ]
    UNEXPECTED RESPONSE: [HTTP/1.0 403 Forbidden
    server: squid/2.5.STABLE1
    mime-version: 1.0
    date: Mon, 15 Oct 2007 17:38:22 GMT
    content-type: text/html
    content-length: 1461
    expires: Mon, 15 Oct 2007 17:38:22 GMT
    x-squid-error: ERR_ACCESS_DENIED 0
    x-cache: MISS from squidserver
    proxy-connection: keep-alive

    ]
    UNEXPECTED RESPONSE: [HTTP/-1163005939.-1163005939 -1163005939

    ]

    QAbstractSocket::UnconnectedState
    socket errorss QAbstractSocket::UnknownSocketError

  2. #2
    Join Date
    Feb 2006
    Location
    Romania
    Posts
    2,744
    Thanks
    8
    Thanked 541 Times in 521 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: QTcpsocket - connection problem

    It is because you make an explicit cast to QObject when you make the connect. There is no need to do that, just pass the socket pointer.

    Qt Code:
    1. connect( m_socket, SIGNAL( proxyAuthenticationRequired ( const QNetworkProxy &, QAuthenticator *) ),this, SLOT( proxyAuthenticationRequiredFunction (
    2.  
    3. const QNetworkProxy &, QAuthenticator * ) ));
    To copy to clipboard, switch view to plain text mode 

Similar Threads

  1. Problem with QTcpSocket in QThread
    By Raistlin in forum Qt Programming
    Replies: 8
    Last Post: 6th October 2007, 12:23
  2. [QMYSQL] connection problem
    By chaos_theory in forum Installation and Deployment
    Replies: 5
    Last Post: 2nd July 2007, 09:52
  3. Strange QTcpSocket behavior (debugged with Ethereal)
    By mdecandia in forum Qt Programming
    Replies: 23
    Last Post: 28th May 2007, 20:44
  4. problem with QTcpSocket
    By SuperSonik in forum Qt Programming
    Replies: 8
    Last Post: 31st January 2007, 16:00
  5. QTcpSocket disconnection problem
    By erdi in forum Qt Programming
    Replies: 4
    Last Post: 19th February 2006, 21:50

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Qt is a trademark of The Qt Company.