PDA

View Full Version : QTcpsocket - connection problem



vishesh
15th October 2007, 20:02
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::ReadWrite);
}



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

marcel
16th October 2007, 18:03
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.



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

const QNetworkProxy &, QAuthenticator * ) ));