PDA

View Full Version : QTcpSocket::connectToHost



yogeshgokul
11th September 2008, 08:38
Hello All,

I am trying to connect using QTcpSocket::connectToHost. This is working fine when I provide host IP (tcpSocket->connectToHost("xx.xx.xx.xx".80)).

But not working when I provide host name (tcpSocket->connectToHost("www.xxx.com".80)).
It seems it not resolving host name.
What can I do ?

yxmaomao
11th September 2008, 10:10
from Qt's document, it should support host name,
Could you try : "At any point, the socket can emit error() to signal that an error occurred. "
to get detailed error information?

yogeshgokul
11th September 2008, 11:09
Its always giving same error. "host not found".

yogeshgokul
11th September 2008, 11:34
I found one more problem with QTcpSocket class.
When we set proxy settings in this class, we need to call QTcpSocket::setProxy(QNetworkProxy("HOST NAME", PORT));

But this is not working at all. Means its setting the proxy but not using that.
It means
case 1:
Proxy server is there("xyz",3128).
QTcpSocket soc;
soc.setProxy(QNetworkProxy("xyz", 3128));
soc.connectToHost("100.100.100.100", 80);

case 2:
Proxy server is not there.
QTcpSocket soc;
soc.connectToHost("100.100.100.100", 80);

case 3:
Proxy server is there("xyz",3128).
QTcpSocket soc;
soc.setProxy(QNetworkProxy("xyz", 3128));
soc.connectToHost("www.yahoo.com", 80);

case 4:
Proxy server is not there.
QTcpSocket soc;
soc.connectToHost("www.yahoo.com", 80);



In this scenario only case 2 will work.
Case 2 will only work because there is no proxy server and we provide IP address instead of host name in function connectToHost.



So there are 2 issues with TCP Socket.

1. Resolving host name e.g soc.connectToHost("www.yahoo.com", 80);
2. Use proxy settings done by e.g. soc.setProxy(QNetworkProxy("xyz", 3128));

jacek
11th September 2008, 20:54
Does it work if you specify the proxy's IP address instead of its name? It looks like name resolution doesn't work on your system.

yogeshgokul
15th September 2008, 07:32
I also thought that and tried already but no luck. I forget to mention that case here.

lengshuang
24th May 2009, 14:38
Today I encounter the same problem!if I use the host name,always the error:host not found!But when I use the IP address,such as :xx.xx.xx.xx,it work perfectly!I don‘t know why

nish
2nd June 2009, 07:12
hey yogesh!! ... are u still stuck with the problem we faced at PSPL??? as far as i remember when we were coding SM2 and working on upload/download muhurta u faced the same problem...

remember PM told that we have hardcoded the website ip in fndef file ...

this remided me of old days... jeevan me chai gala sek kar peene ka maja he kuch aur tha..

:cool::cool::cool:

yogeshgokul
2nd June 2009, 10:36
Yes this is same problem, but now resolved in latest qt build 4.5.X. ha yaar wo din to mast hi the jab appan 3 din me apps bana ke fek dete the.. iski maka naka kar dete the

nish
2nd June 2009, 10:37
mujhe to ab bhi lagta hai ki hum 3 din me app bana ke pani ka gilaas manager ke muh pe mar sakte hain:D:D:D

nish
2nd June 2009, 10:39
aur jab wo apni aankhe mal raha hoga to kya kehna/karna chahiye?

yogeshgokul
3rd July 2009, 08:22
uska haath aakho pe se hata ke, kheech ke lappad laga te hai,

nish
6th July 2009, 11:29
bilkul sahi jawab.. arre kukur tu to bilkul nahi badla re

wysota
6th July 2009, 12:11
Guys, after all this is an English spoken site. If you want to talk in private, use the private messaging system.

nish
6th July 2009, 14:17
inbox size is too very small. we are long lost friends, so just over excited i think. :)

wysota
6th July 2009, 14:43
inbox size is too very small.
We're low on resources. It's either private messages or forum threads with attachments.

we are long lost friends, so just over excited i think. :)

Ever heard of emails? :)

nish
6th July 2009, 14:47
We're low on resources. It's either private messages or forum threads with attachments.
oh.. okay.



Ever heard of emails? :)
the place where i am currently in has blocked internet. Ever heard of the great (Fire)Wall of china?

sophister
7th July 2009, 10:33
You mean there is the same fire wall in Taiwan as in China mainland??
I thought only our mainland has that fire wall

nish
7th July 2009, 11:42
no ... i ment that in our office there is a firewall, we dont have access to anything. only 10-15 websites are allowed.

but there is some degree of firewall in taiwan i think... i cannot open sites ending with .mil(millitary?) at public computers.