[Twisted-web] resolving a hostname problem

Raphael Arbuz raphaelarbuz at netcourrier.com
Wed Aug 24 11:28:34 MDT 2005


Sorry, here is a more complete listing of the part that could help:

import wx
from threading import Thread
from twisted.internet import reactor
from twisted.python import threadable
from twisted.internet.defer import maybeDeferred, Deferred
from twisted.internet import defer
from time import sleep
from time import time
from communication import Communication

from twisted.internet.task import LoopingCall
from twisted.internet.protocol import DatagramProtocol

import sys, traceback
import audio
import Queue

import ConnectionManager

class TwistedThread(Thread, DatagramProtocol):

    def __init__(self, appliClass, fileID, queue):
        Thread.__init__(self) # initialize the thread

        self.appliClass = appliClass
        self.fileID = fileID
        self.queue = queue

    def run(self):
        """after the thread is launched"""
        threadable.init(1)
        self.waitForCalls()
        while 1:
            msg = self.queue.get(1)
            if msg[0]=="call":
                  self.resolve(IP = msg[1], password = msg[2])
                break

    def waitForCalls(self):
        """open MAX_NB_CORRESPONDENTS ports to listen to incoming
connections"""
        print "waiting for calls"
        for counter in range(self.appliClass.MAX_NB_CORRESPONDENTS):
            correspondent = ConnectionManager.ConnectionManager(self,
self.sendPointer, False)
            try:
                reactor.listenUDP(8000+counter,
self.correspondents[counter])
            except:
                pass
        reactor.run(installSignalHandlers=0)

    def resolve(self, IP, distPort= 8000, password = "", destroy = False):
        print "on res"
        dd = reactor.resolve(IP)
        dd.addCallback(self.call, distPort, password, destroy)

    def call(self, IP, distPort = 8000, password = "", destroy = False):
        print "res done"
        """place a phone call"""
        print "Calling the IP " + str(IP) + " on port " + str(distPort)
        self.confPassword = password #set the conference password
....


Hope it is clearer.

Thanks a lot for your time

Raphael



----- Original Message -----
From: "Tommi Virtanen" <tv at twistedmatrix.com>
To: "Discussion of twisted.web, Nevow, and Woven"
<twisted-web at twistedmatrix.com>
Sent: Wednesday, August 24, 2005 6:15 PM
Subject: Re: [Twisted-web] resolving a hostname problem


> Raphael Arbuz wrote:
> > I;m trying to impleting hostname resolution in a program that aimed to
> > exchange UDP packets with his peers.
> >
> > What I do is add the two lines:
> >     dd = reactor.resolve(IP)
> >     dd.addCallback(self.call, distPort, password, destroy)
> >
> > To my program, but when I do that, I don't reach the call function.
Seems
> > like something would be missing. Does anyone have a clue?
>
> Yes, we do.
>
> What is missing is the rest of your program; that is, the parts
> that contain the bug.
>
> You owe the Oracle a bottle of crystal ball polish[1].
>
>
> [1] You ain't an old beard if you don't know what that refers to.[2]
>
> [2] Yes, the grovel _was_ insufficient.
>
> _______________________________________________
> Twisted-web mailing list
> Twisted-web at twistedmatrix.com
> http://twistedmatrix.com/cgi-bin/mailman/listinfo/twisted-web
>




More information about the Twisted-web mailing list