[Twisted-Python] Using FQDN with transport.write calls...

My application requires that I use FQDN in place of the normal IP addresses in transport.write calls. In looking over I see quite a few places called 'resolveAddress', which look like they do exactly what I need. I was wondering if anyone has a code snippet that would show me exactly what I need to do?
TIA, Chaz

On Sun, 13 Aug 2006 07:28:51 -0400, "Chaz." eprparadocs@gmail.com wrote:
My application requires that I use FQDN in place of the normal IP addresses in transport.write calls.
No it doesn't. What behavior would you expect this to provide which you desire in your application?
Jean-Paul

I actually see reactor has a resolve() method that looks like it is used. But in looking at the Posix implementation it appears to be "blocking" (unless threading is around in which case it uses a thread).
So I am now wondering the following:
1) Is the default resolve() method, blocking? 2) How do I get it to use the thread version?
Chaz
Jean-Paul Calderone wrote:
On Sun, 13 Aug 2006 07:28:51 -0400, "Chaz." eprparadocs@gmail.com wrote:
My application requires that I use FQDN in place of the normal IP addresses in transport.write calls.
No it doesn't. What behavior would you expect this to provide which you desire in your application?
Jean-Paul

On Sun, 13 Aug 2006 13:23:42 -0400, Chaz eprparadocs@gmail.com wrote:
Jean-Paul Calderone wrote:
On Sun, 13 Aug 2006 07:28:51 -0400, "Chaz." eprparadocs@gmail.com wrote:
My application requires that I use FQDN in place of the normal IP addresses in transport.write calls.
No it doesn't. What behavior would you expect this to provide which you desire in your application?
Jean-Paul
I actually see reactor has a resolve() method that looks like it is used. But in looking at the Posix implementation it appears to be "blocking" (unless threading is around in which case it uses a thread).
So I am now wondering the following:
- Is the default resolve() method, blocking?
- How do I get it to use the thread version?
Chaz
You didn't answer my question. Also, please don't top-post.
Jean-Paul

Jean-Paul Calderone wrote:
On Sun, 13 Aug 2006 13:23:42 -0400, Chaz eprparadocs@gmail.com wrote:
Jean-Paul Calderone wrote:
On Sun, 13 Aug 2006 07:28:51 -0400, "Chaz." eprparadocs@gmail.com wrote:
My application requires that I use FQDN in place of the normal IP addresses in transport.write calls.
No it doesn't. What behavior would you expect this to provide which you desire in your application?
Jean-Paul
I actually see reactor has a resolve() method that looks like it is used. But in looking at the Posix implementation it appears to be "blocking" (unless threading is around in which case it uses a thread).
So I am now wondering the following:
- Is the default resolve() method, blocking?
- How do I get it to use the thread version?
Chaz
You didn't answer my question. Also, please don't top-post.
Jean-Paul
Twisted-Python mailing list Twisted-Python@twistedmatrix.com http://twistedmatrix.com/cgi-bin/mailman/listinfo/twisted-python
Sorry for the top-post. What I want to do is the following
self.transport.write(data,('www.foobar.com',6000))
I think that says it succinctly.
As I see it I need to do some things with defer and reactor.resolve() or use socket.getaddrinfo() or socket.gethostbyname() and deal with the possible blocking nature of these calls.
As I said in my follow-on post I see the implementation of resolve() in the posix reactor support and wonder about the two methods I see there: the blocking one and the thread one. How do I get to decide which is used.
Finally is there some, unknown to me, way to already deal with this issue?
Peace, Chaz.

On 14 Aug 2006, at 06:38, Chaz. wrote:
Jean-Paul Calderone wrote:
On Sun, 13 Aug 2006 07:28:51 -0400, "Chaz." eprparadocs@gmail.com wrote:
My application requires that I use FQDN in place of the normal IP addresses in transport.write calls.
No it doesn't. What behavior would you expect this to provide which you desire in your application?
Sorry for the top-post. What I want to do is the following
self.transport.write(data,('www.foobar.com',6000))
I think that says it succinctly.
I think that Jean-Paul was trying to say something like this: "self.transport is a file-like object, so its write() method takes only data. It wouldn't make sense to supply an IP address and port to sys.stdout.write(), why do you expect that self.transport.write() would accept one?"

Tim Allen wrote:
On 14 Aug 2006, at 06:38, Chaz. wrote:
Jean-Paul Calderone wrote:
On Sun, 13 Aug 2006 07:28:51 -0400, "Chaz." eprparadocs@gmail.com wrote:
My application requires that I use FQDN in place of the normal IP addresses in transport.write calls.
No it doesn't. What behavior would you expect this to provide which you desire in your application?
Sorry for the top-post. What I want to do is the following
self.transport.write(data,('www.foobar.com',6000))
I think that says it succinctly.
I think that Jean-Paul was trying to say something like this: "self.transport is a file-like object, so its write() method takes only data. It wouldn't make sense to supply an IP address and port to sys.stdout.write(), why do you expect that self.transport.write() would accept one?"
Because it does for datagrams, and that is how I am using it. What I am asking, is instead of supplying an (IP address, port) I would like to use (fqdn,port). There are sometimes I want to use the DNS system to resolve the address.
Chaz

On Sun, 13 Aug 2006 17:38:17 -0400, "Chaz." eprparadocs@gmail.com wrote:
Tim Allen wrote:
On 14 Aug 2006, at 06:38, Chaz. wrote:
Jean-Paul Calderone wrote:
On Sun, 13 Aug 2006 07:28:51 -0400, "Chaz." eprparadocs@gmail.com wrote: >My application requires that I use FQDN in place of the normal IP >addresses in transport.write calls.
No it doesn't. What behavior would you expect this to provide which you desire in your application?
Sorry for the top-post. What I want to do is the following
self.transport.write(data,('www.foobar.com',6000))
I think that says it succinctly.
I think that Jean-Paul was trying to say something like this: "self.transport is a file-like object, so its write() method takes only data. It wouldn't make sense to supply an IP address and port to sys.stdout.write(), why do you expect that self.transport.write() would accept one?"
Because it does for datagrams, and that is how I am using it. What I am asking, is instead of supplying an (IP address, port) I would like to use (fqdn,port). There are sometimes I want to use the DNS system to resolve the address.
So, you want to resolve a name to an address? Sorry, it was very unclear from your initial question that that was your goal. This is easily done, and you have already correctly identifier the API to use, reactor.resolve().
Jean-Paul

On Sun, 2006-08-13 at 13:23 -0400, Chaz wrote:
I actually see reactor has a resolve() method that looks like it is used. But in looking at the Posix implementation it appears to be "blocking" (unless threading is around in which case it uses a thread).
So I am now wondering the following:
- Is the default resolve() method, blocking?
- How do I get it to use the thread version?
It uses the threaded version by default on virtually all platforms.
participants (5)
-
Chaz
-
Chaz.
-
Itamar Shtull-Trauring
-
Jean-Paul Calderone
-
Tim Allen