Ticket #373 (new enhancement )

Opened 5 years ago

Last modified 5 years ago

binding interface feature request

Reported by: maoy Assigned to: itamarst
Type: enhancement Priority: normal
Milestone: Component:
Keywords: Cc: spiv, itamarst, jknight, maoy
Branch: Author:
Launchpad Bug:

Attachments

twisted.txt (1.9 kB) - added by maoy 5 years ago.

Change History

  2003-10-29 00:13:56+00:00 changed by maoy

  • attachment twisted.txt added

  2003-10-29 00:13:56+00:00 changed by maoy

please add features for connectTCP to bind to specific interfaces
i have a quick hack in mind as the attached file shows.

  2003-10-30 07:18:11+00:00 changed by spiv

Your diff is backwards.  Also, unidiff format (pass the "-u" option to diff)
much easier to read!
It looks like a fairly minimal change, but I think we'd need some way to sanely
raise an intelligible exception if someone tried to do this on a platform that
doesn't support it.  A cryptic socket.error from the guts of Twisted would
confuse users.  (On the other hand, network device names are probably
platform-specific anyway, so perhaps this doesn't matter so much...)
Also, I think I'd prefer the new argument to be called "device", rather than
"interface".  Oh, and we'd need to change twisted/internet/interfaces.py and all
the reactor implementations, not just default.py.
Anyway, thanks for the patch -- it's a good starting point for discussion :)

  2003-10-31 11:25:25+00:00 changed by itamarst

I'm not sure how happy I'd be adding this... How about a function that gets the
IP address for an interface?

  2003-10-31 11:34:51+00:00 changed by maoy

Hi,
 if you are sure that this works, together with bindAddress, as same as
bindInterface, I would love to use this way. However, according to my test
(with manually feeded IP address for interface), it didn't work well.
Is there an alternative that I don't have to modify the twisted source
code, and somehow inherit a class to make this happen? In particular, I
don't know how to get my own reactor for the modified connectTCP
function.. Thanks.
Yun
On Fri, 31 Oct 2003, Itamar Shtull-Trauring [Twisted issue tracker] wrote:
>
> Itamar Shtull-Trauring <itamar@itamarst.org> added the comment:
>
> I'm not sure how happy I'd be adding this... How about a function that gets the
> IP address for an interface?
> ____________________________________________________________________
> Twisted issue tracker <twisted.roundup@twistedmatrix.com>
> <http://www.twistedmatrix.com/users/roundup.twistd/twisted/#373>
> ____________________________________________________________________
>

  2004-03-08 01:53:13+00:00 changed by jknight

What's the use for this? It seems to me that applications pretty much always bind to IP addresses (and,
by doing so possibly an interface). I don't recall ever having seen an server that let me configure the
interface it listens on as opposed to the address, and I can't say I've missed the ability too, either.

  2004-03-08 01:59:02+00:00 changed by maoy

This is mainly for client side. Imagine you have wireless and ethernet
interfaces available at the same time, and by doing this you can have the
opportunity of using both of them. Binding IP address here doesn't do the
job.
On Sun, 7 Mar 2004, James Knight [Twisted issue tracker] wrote:
>
> James Knight <foom@fuhm.net> added the comment:
>
> What's the use for this? It seems to me that applications pretty much always bind to IP addresses (and,
> by doing so possibly an interface). I don't recall ever having seen an server that let me configure the
> interface it listens on as opposed to the address, and I can't say I've missed the ability too, either.
> ____________________________________________________________________
> Twisted issue tracker <twisted.roundup@twistedmatrix.com>
> <http://www.twistedmatrix.com/users/roundup.twistd/twisted/#373>
> ____________________________________________________________________
>

  2004-03-16 02:27:09+00:00 changed by jknight

I still don't understand. "Use both of them"?

  2004-03-18 16:36:03+00:00 changed by jknight

You want to do load balancing between multiple possible routes to the same destination at the
application level? That seems like an edge case to me.
It should be possible from my reading of the code to override Client.createInternetSocket() to call
self.socket.setsockopt(...SO_BINDTODEVICE...) after calling the super doConnect in order to have this
functionality without it being in twisted.
Looking harder, though, I find that...
The only problem is that it's seemingly impossible to use a custom Client class, since it's referenced
directly from tcp.Connector, which is referenced from reactor.connectTCP. I am actually completely
boggled by tcp.Connector, it seems like a "Client" class should suffice. In fact, I'm also boggled by
reactor having a connectTCP method, instead of having people just construct a Client object directly.
Doing what maoy wants should be a simple thing without needing to add it to twisted, but it doesn't
seem to be...
Note: See TracTickets for help on using tickets.