Em seg 21 abr 2014, às 18:09:59, Thiago Macieira escreveu: > And besides, it's not 75 seconds. It's 127 seconds, per IP address. > > $ strace -r telnet 192.0.2.1 1024 |& grep -A1 connect.*192.0.2.1 > 0.000018 connect(3, {sa_family=AF_INET, sin_port=htons(1024), > sin_addr=inet_addr("192.0.2.1")}, 16) = -1 ETIMEDOUT (Connection timed out) > 127.278591 write(2, "telnet: connect to address 192.0"..., 59telnet: > connect to address 192.0.2.1: Connection timed out > ) = 59 > > If it's something with multiple IP addresses:
I forgot to wait for the command to finish: $ time telnet a-multi.test.qt-project.org 1024 Trying 192.0.2.1... telnet: connect to address 192.0.2.1: Connection timed out Trying 192.0.2.2... telnet: connect to address 192.0.2.2: Connection timed out Trying 192.0.2.3... telnet: connect to address 192.0.2.3: Connection timed out telnet a-multi.test.qt-project.org 1024 0,00s user 0,00s system 0% cpu 6:21.68 total It took 6:21 minutes for this command to finish. With QTcpSocket, it runs in 3 minutes and tries each IP address twice: $ time strace -re connect ./a.out 0.000000 connect(5, {sa_family=AF_INET, sin_port=htons(1024), sin_addr=inet_addr("192.0.2.1")}, 16) = -1 EINPROGRESS (Operation now in progress) 30.024752 connect(4, {sa_family=AF_INET, sin_port=htons(1024), sin_addr=inet_addr("192.0.2.2")}, 16) = -1 EINPROGRESS (Operation now in progress) 30.029888 connect(4, {sa_family=AF_INET, sin_port=htons(1024), sin_addr=inet_addr("192.0.2.3")}, 16) = -1 EINPROGRESS (Operation now in progress) 30.018024 connect(4, {sa_family=AF_INET, sin_port=htons(1024), sin_addr=inet_addr("192.0.2.1")}, 16) = -1 EINPROGRESS (Operation now in progress) 30.031005 connect(4, {sa_family=AF_INET, sin_port=htons(1024), sin_addr=inet_addr("192.0.2.2")}, 16) = -1 EINPROGRESS (Operation now in progress) 30.014966 connect(4, {sa_family=AF_INET, sin_port=htons(1024), sin_addr=inet_addr("192.0.2.3")}, 16) = -1 EINPROGRESS (Operation now in progress) 30.032129 +++ exited with 1 +++ strace -re connect ./a.out 0,01s user 0,02s system 0% cpu 3:00,17 total PS: the timeout is actually 30 ± 1 s, due to the VeryCoarseTimer functionality. -- Thiago Macieira - thiago.macieira (AT) intel.com Software Architect - Intel Open Source Technology Center
#include <QtNetwork/QtNetwork> int main(int argc, char **argv) { QCoreApplication app(argc, argv); QTcpSocket socket; socket.connectToHost("a-multi.test.qt-project.org", 1024); return socket.waitForConnected(INT_MAX) ? EXIT_SUCCESS : EXIT_FAILURE; }
_______________________________________________ Interest mailing list Interest@qt-project.org http://lists.qt-project.org/mailman/listinfo/interest