twisted: not doing DNS resolutions?

Discussion in 'Python' started by Christopher Subich, Jun 30, 2005.

  1. I'm building an application that makes several user-specified internet
    connections; twisted meets my needs more or less perfectly.

    I'm running into a problem, however, in that twisted is not allowing
    connections (reactor.connectTCP) by hostname, only IP address. [read:
    connections to IP addresses work fine, hostnames no]

    From what I can tell, the problem lies in that Twisted simply isn't
    performing the DNS resolutions. From the connection factory's
    startedConnecting method, print connector.getDestination() results in:

    IPv4Address(TCP, 'hostname', port)

    That is to say, the port is correct, but the 'hostname' is completely
    unresolved. Since 'hostname' is a really bad IP address, not being one
    at all, the connection of course fails. A check via tcpdump on my
    gateway machine shows that the DNS resolution doesn't occur.

    The API documentation for version 1.3 (I'm using 2.0.1, but a quick
    check of twisted source/docstrings shows this to be still true[1]) shows
    that connectTCP taks "a host name," so by that (and the echo client
    example that connects to 'localhost') I presume there's supposed to be
    some sort of resolution going on.

    I'm running twisted 2.0.1 on win32. Is this a bug in twisted, or is
    there some configuration that I've gone and borked?

    [1] -- is there some reason in particular that there's no API reference
    for twisted 2.0x? The documentation/tutorials are pretty sparse as-is, I
    think.
     
    Christopher Subich, Jun 30, 2005
    #1
    1. Advertisements

  2. Christopher Subich wrote:
    > From what I can tell, the problem lies in that Twisted simply isn't
    > performing the DNS resolutions. From the connection factory's
    > startedConnecting method, print connector.getDestination() results in:
    >
    > IPv4Address(TCP, 'hostname', port)


    Update: after doing some diving in the twisted source, it is supposed to
    do that. My guess is that either it thinks the hostname is a valid ip
    address (unlikely), or a callback isn't actually getting called. This
    confuses me.
     
    Christopher Subich, Jun 30, 2005
    #2
    1. Advertisements

  3. Christopher Subich wrote:
    > Christopher Subich wrote:
    >
    >> From what I can tell, the problem lies in that Twisted simply isn't
    >> performing the DNS resolutions. From the connection factory's


    .... right, finally figured it out after a very long time at debugging
    the beast.

    It's an interaction with IDLE.

    What happens is that the deferToThread call in twisted's lookup Just
    Doesn't Run Right (under some circumstances) when it's run under IDLE
    with tksupport. I finally got the idea to run the application from the
    command line, and it worked just fine. This is kind of odd, since a
    trivial test case run from the interactive idle prompt works okay, but
    it's now 5am and I'm going to sleep.

    Moral: beware the IDLEs of March.
     
    Christopher Subich, Jun 30, 2005
    #3
    1. Advertisements

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Joe Bonavita

    form size with different client resolutions

    Joe Bonavita, Dec 19, 2003, in forum: ASP .Net
    Replies:
    5
    Views:
    580
    Joe Bonavita
    Dec 23, 2003
  2. Bluetears76
    Replies:
    1
    Views:
    1,185
    Larry Barowski
    Jul 1, 2004
  3. steve
    Replies:
    2
    Views:
    451
    steve
    Apr 14, 2006
  4. Sebastian Sowa

    screen resolutions

    Sebastian Sowa, Jul 3, 2003, in forum: HTML
    Replies:
    31
    Views:
    1,454
    Isofarro
    Jul 5, 2003
  5. Joe Patrick

    Resolutions

    Joe Patrick, Aug 31, 2003, in forum: HTML
    Replies:
    5
    Views:
    454
    Isofarro
    Aug 31, 2003
  6. Christian Seberino
    Replies:
    1
    Views:
    821
    Andrew Bennetts
    Apr 13, 2004
  7. Sam Roberts
    Replies:
    0
    Views:
    400
    Sam Roberts
    Mar 20, 2005
  8. gavino
    Replies:
    2
    Views:
    331
    Ted Zlatanov
    Jul 27, 2006
Loading...