class: IPSocketAddress
authorStefan Vogel <sv@exept.de>
Fri, 27 Feb 2015 22:09:14 +0100
changeset 3510 51b43eca349f
parent 3509 24cf2cef907c
child 3511 f23e77f37681
class: IPSocketAddress added: #asIPv4SocketAddressIfPossible #hasSameHostAddress: comment/format in: #networkAddress
IPSocketAddress.st
--- a/IPSocketAddress.st	Thu Feb 26 11:01:22 2015 +0100
+++ b/IPSocketAddress.st	Fri Feb 27 22:09:14 2015 +0100
@@ -370,12 +370,26 @@
     self unsignedShortAt:3 put:aPortNr bigEndian:true
 ! !
 
+!IPSocketAddress methodsFor:'comparing'!
+
+hasSameHostAddress:aSocketAddress
+    "answer true, if myself and aSocketAddress have the same host address
+     (but possibly different ports)."
+
+    ^ aSocketAddress class == self class 
+        and:[self sameContentsFrom:5 to:9 as:aSocketAddress startingAt:5]
+! !
+
 !IPSocketAddress methodsFor:'converting'!
 
 asIPv4SocketAddress
     ^ self
 !
 
+asIPv4SocketAddressIfPossible
+    ^ self
+!
+
 asIPv6SocketAddress
     "convert a IPv4 address to a mapped IPv6SocketAddress"
 
@@ -478,7 +492,7 @@
 
 networkAddress
     "THINK TWICE before using this!! 
-     This is deprecated, it doesn't make sense any longer since subnetting and netmasks
+     This is deprecated, it doesn't make sense any longer since CIDR, subnetting and netmasks
      have been introduced.
 
      Extract and return the network part from the host address."
@@ -595,10 +609,10 @@
 !IPSocketAddress class methodsFor:'documentation'!
 
 version
-    ^ '$Header: /cvs/stx/stx/libbasic2/IPSocketAddress.st,v 1.43 2015-02-26 10:00:31 stefan Exp $'
+    ^ '$Header: /cvs/stx/stx/libbasic2/IPSocketAddress.st,v 1.44 2015-02-27 21:09:14 stefan Exp $'
 !
 
 version_CVS
-    ^ '$Header: /cvs/stx/stx/libbasic2/IPSocketAddress.st,v 1.43 2015-02-26 10:00:31 stefan Exp $'
+    ^ '$Header: /cvs/stx/stx/libbasic2/IPSocketAddress.st,v 1.44 2015-02-27 21:09:14 stefan Exp $'
 ! !