Re: sockets: bind to external interface

2011-04-26 Thread Jean-Michel Pichavant
Hans Georg Schaathun wrote: Is there a simple way to find the external interface and bind a socket to it, when the hostname returned by socket.gethostname() maps to localhost? What seems to be the standard ubuntu configuration lists the local hostname with 127.0.0.1 in /etc/hosts. (I checked th

Re: sockets: bind to external interface

2011-04-25 Thread Hans Georg Schaathun
On Mon, 25 Apr 2011 23:18:05 +0200, Thomas Rachel wrote: : That is right, but I cannot see where he mentions the "direction" of the : socket. My fist thought was that he tries to have a server socket... Quite right. I thought it was implied by the need to bind :-) Sorry for the lack of deta

Re: sockets: bind to external interface

2011-04-25 Thread Chris Angelico
On Tue, Apr 26, 2011 at 7:18 AM, Thomas Rachel wrote: > Am 25.04.2011 22:30, schrieb Chris Angelico: > >> If you don't care what port you use, you don't need to bind at all. >> That may be why it's not mentioned - the classic TCP socket server >> involves bind/listen/accept, and the classic TCP cl

Re: sockets: bind to external interface

2011-04-25 Thread Thomas Rachel
Am 25.04.2011 22:30, schrieb Chris Angelico: If you don't care what port you use, you don't need to bind at all. That may be why it's not mentioned - the classic TCP socket server involves bind/listen/accept, and the classic TCP client has just connect; bind/connect is a lot less common. That

Re: sockets: bind to external interface

2011-04-25 Thread Thomas Rachel
Am 25.04.2011 22:14 schrieb Hans Georg Schaathun: On Tue, 26 Apr 2011 05:49:07 +1000, Chris Angelico wrote: : The way you talk of "the" external interface, I'm assuming this : computer has only one. Is there a reason for not simply binding to : INADDR_ANY aka 0.0.0.0? Ah. That's wha

Re: sockets: bind to external interface

2011-04-25 Thread Chris Angelico
On Tue, Apr 26, 2011 at 6:24 AM, Hans Georg Schaathun wrote: > Hmmm.  socket.INADDR_ANY is an integer and bind insists on a string > for the hostname (Python 2.6).  Is there any use for the integer > constant?  "0.0.0.0" does exactly what I wanted though.  Thanks again. Apologies - I've done mos

Re: sockets: bind to external interface

2011-04-25 Thread Chris Angelico
On Tue, Apr 26, 2011 at 6:14 AM, Hans Georg Schaathun wrote: > :  The way you talk of "the" external interface, I'm assuming this > :  computer has only one. Is there a reason for not simply binding to > :  INADDR_ANY aka 0.0.0.0? > > Ah.  That's what I really wanted.  Thanks a lot.  I wonder why

Re: sockets: bind to external interface

2011-04-25 Thread Hans Georg Schaathun
On Mon, 25 Apr 2011 21:14:51 +0100, Hans Georg Schaathun wrote: : : The way you talk of "the" external interface, I'm assuming this : : computer has only one. Is there a reason for not simply binding to : : INADDR_ANY aka 0.0.0.0? : : Ah. That's what I really wanted. Thanks a lot. I wond

Re: sockets: bind to external interface

2011-04-25 Thread Hans Georg Schaathun
On Tue, 26 Apr 2011 05:49:07 +1000, Chris Angelico wrote: : You can run 'ifconfig' without being root, so there must be a way. At : very worst, parse ifconfig's output. Of course, but I am not sure that's simpler than the manual solution. Especially since there is more than one version of ifc

Re: sockets: bind to external interface

2011-04-25 Thread Jean-Paul Calderone
On Apr 25, 3:49 pm, Chris Angelico wrote: > On Tue, Apr 26, 2011 at 5:37 AM, Hans Georg Schaathun > wrote: > > > Has anyone found a simple solution that can be administered without > > root privileges?  I mean simpler than passing the ip address > > manually :-) > > You can run 'ifconfig' withou

Re: sockets: bind to external interface

2011-04-25 Thread Chris Angelico
On Tue, Apr 26, 2011 at 5:37 AM, Hans Georg Schaathun wrote: > Has anyone found a simple solution that can be administered without > root privileges?  I mean simpler than passing the ip address > manually :-) You can run 'ifconfig' without being root, so there must be a way. At very worst, parse

sockets: bind to external interface

2011-04-25 Thread Hans Georg Schaathun
Is there a simple way to find the external interface and bind a socket to it, when the hostname returned by socket.gethostname() maps to localhost? What seems to be the standard ubuntu configuration lists the local hostname with 127.0.0.1 in /etc/hosts. (I checked this on two ubuntu boxen, on onl