Question regarding name lookups on the loopback device

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
2 messages Options
Reply | Threaded
Open this post in threaded view
|

Question regarding name lookups on the loopback device

Holger Freyther
Hi,

should SocketAddress byName: (SocketAddress loopbackHost) equal to
SocketAddress loopbackHost? On my Fedora system my hostname is turning up
multiple names in the /etc/hosts (see below) file. The resolving of the name
'bla' ends up with an IPv6 address. I am not sure I added this entry or if the
fedora setup did and how to handle this. Is IPv6 support 'opaque' in the
Smalltalk Socket classes?


192.168.0.181 bla #Added by NetworkManager
127.0.0.1 localhost.localdomain localhost
::1 bla localhost6.localdomain localhost6


_______________________________________________
help-smalltalk mailing list
[hidden email]
http://lists.gnu.org/mailman/listinfo/help-smalltalk
Reply | Threaded
Open this post in threaded view
|

Re: Question regarding name lookups on the loopback device

Paolo Bonzini-2
Hi Holger,

sorry for the late reply.

On 03/06/2011 01:59 PM, Holger Hans Peter Freyther wrote:
> should SocketAddress byName: (SocketAddress loopbackHost) equal to
                                ^^^^^^^^^^^^^^^^^^^^^^^^^^^^

You mean 'localhost' or "SocketAddress localHostName" here.

> SocketAddress loopbackHost?

It isn't, but it is a plausible requirement.

Right now, #byName: is returning a random address, but preferring one
for the default address class is a good idea.

Does this patch satisfy your needs?

diff --git a/packages/sockets/SocketAddress.st
b/packages/sockets/SocketAddress.st
index 6af7176..2370d40 100644
--- a/packages/sockets/SocketAddress.st
+++ b/packages/sockets/SocketAddress.st
@@ -277,7 +277,8 @@ and vice versa.'>
  aString isEmpty ifTrue: [^self loopbackHost].
  all := self allByName: aString.
  all isNil ifTrue: [^nil].
- ^all anyOne
+ ^all detect: [:each | each isKindOf: Socket defaultAddressClass]
+            ifNone: [all anyOne]
      ]

      SocketAddress class >> extractAddressesAfterLookup: aiHead [

Paolo

_______________________________________________
help-smalltalk mailing list
[hidden email]
http://lists.gnu.org/mailman/listinfo/help-smalltalk